Search in sources :

Example 11 with COSObjectable

use of com.tom_roush.pdfbox.pdmodel.common.COSObjectable in project PdfBox-Android by TomRoush.

the class FDFField method setValue.

/**
 * You should pass in a string, or a java.util.List of strings to set the value.
 *
 * @param value The value that should populate when imported.
 *
 * @throws IOException If there is an error setting the value.
 */
public void setValue(Object value) throws IOException {
    COSBase cos = null;
    if (value instanceof List) {
        cos = COSArrayList.convertStringListToCOSStringCOSArray((List<String>) value);
    } else if (value instanceof String) {
        cos = new COSString((String) value);
    } else if (value instanceof COSObjectable) {
        cos = ((COSObjectable) value).getCOSObject();
    } else if (value != null) {
        throw new IOException("Error:Unknown type for field import" + value);
    }
    field.setItem(COSName.V, cos);
}
Also used : COSObjectable(com.tom_roush.pdfbox.pdmodel.common.COSObjectable) COSBase(com.tom_roush.pdfbox.cos.COSBase) NodeList(org.w3c.dom.NodeList) ArrayList(java.util.ArrayList) List(java.util.List) COSArrayList(com.tom_roush.pdfbox.pdmodel.common.COSArrayList) COSString(com.tom_roush.pdfbox.cos.COSString) IOException(java.io.IOException) COSString(com.tom_roush.pdfbox.cos.COSString)

Aggregations

COSObjectable (com.tom_roush.pdfbox.pdmodel.common.COSObjectable)11 PDNumberTreeNode (com.tom_roush.pdfbox.pdmodel.common.PDNumberTreeNode)6 COSBase (com.tom_roush.pdfbox.cos.COSBase)5 COSArray (com.tom_roush.pdfbox.cos.COSArray)4 PDStructureTreeRoot (com.tom_roush.pdfbox.pdmodel.documentinterchange.logicalstructure.PDStructureTreeRoot)4 COSInteger (com.tom_roush.pdfbox.cos.COSInteger)3 PDDocument (com.tom_roush.pdfbox.pdmodel.PDDocument)3 File (java.io.File)3 Test (org.junit.Test)3 COSDictionary (com.tom_roush.pdfbox.cos.COSDictionary)2 COSName (com.tom_roush.pdfbox.cos.COSName)2 COSObject (com.tom_roush.pdfbox.cos.COSObject)2 COSStream (com.tom_roush.pdfbox.cos.COSStream)2 PDDocumentCatalog (com.tom_roush.pdfbox.pdmodel.PDDocumentCatalog)2 PDPage (com.tom_roush.pdfbox.pdmodel.PDPage)2 PDParentTreeValue (com.tom_roush.pdfbox.pdmodel.documentinterchange.logicalstructure.PDParentTreeValue)2 PDAnnotation (com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAnnotation)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 List (java.util.List)2