Search in sources :

Example 11 with COSString

use of com.tom_roush.pdfbox.cos.COSString in project PdfBox-Android by TomRoush.

the class COSArrayList method add.

/**
 * {@inheritDoc}
 */
@Override
public void add(int index, E element) {
    // in the dictionary from a single item to an array.
    if (parentDict != null) {
        parentDict.setItem(dictKey, array);
        // clear the parent dict so it doesn't happen again, there might be
        // a usecase for keeping the parentDict around but not now.
        parentDict = null;
    }
    actual.add(index, element);
    if (element instanceof String) {
        array.add(index, new COSString((String) element));
    } else {
        array.add(index, ((COSObjectable) element).getCOSObject());
    }
}
Also used : COSString(com.tom_roush.pdfbox.cos.COSString) COSString(com.tom_roush.pdfbox.cos.COSString)

Example 12 with COSString

use of com.tom_roush.pdfbox.cos.COSString in project PdfBox-Android by TomRoush.

the class COSArrayList method toCOSObjectList.

private List<COSBase> toCOSObjectList(Collection<?> list) {
    List<COSBase> cosObjects = new ArrayList<COSBase>();
    for (Object next : list) {
        if (next instanceof String) {
            cosObjects.add(new COSString((String) next));
        } else {
            COSObjectable cos = (COSObjectable) next;
            cosObjects.add(cos.getCOSObject());
        }
    }
    return cosObjects;
}
Also used : ArrayList(java.util.ArrayList) COSBase(com.tom_roush.pdfbox.cos.COSBase) COSObject(com.tom_roush.pdfbox.cos.COSObject) COSString(com.tom_roush.pdfbox.cos.COSString) COSString(com.tom_roush.pdfbox.cos.COSString)

Example 13 with COSString

use of com.tom_roush.pdfbox.cos.COSString in project PdfBox-Android by TomRoush.

the class FDFJavaScript method setDoc.

/**
 * Sets the dictionary's "Doc" entry.
 *
 * @param map Map of named "JavaScript" dictionaries.
 */
public void setDoc(Map<String, PDActionJavaScript> map) {
    COSArray array = new COSArray();
    for (Map.Entry<String, PDActionJavaScript> entry : map.entrySet()) {
        array.add(new COSString(entry.getKey()));
        array.add(entry.getValue());
    }
    dictionary.setItem(COSName.DOC, array);
}
Also used : COSArray(com.tom_roush.pdfbox.cos.COSArray) COSString(com.tom_roush.pdfbox.cos.COSString) PDActionJavaScript(com.tom_roush.pdfbox.pdmodel.interactive.action.PDActionJavaScript) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) COSString(com.tom_roush.pdfbox.cos.COSString)

Example 14 with COSString

use of com.tom_roush.pdfbox.cos.COSString in project PdfBox-Android by TomRoush.

the class PDFontDescriptor method getCharSet.

/**
 * This will get the character set for the font.
 *
 * @return The character set value.
 */
public String getCharSet() {
    String retval = null;
    COSString name = (COSString) dic.getDictionaryObject(COSName.CHAR_SET);
    if (name != null) {
        retval = name.getString();
    }
    return retval;
}
Also used : COSString(com.tom_roush.pdfbox.cos.COSString) COSString(com.tom_roush.pdfbox.cos.COSString)

Example 15 with COSString

use of com.tom_roush.pdfbox.cos.COSString in project PdfBox-Android by TomRoush.

the class PDFontDescriptor method setFontFamily.

/**
 * This will set the font family.
 *
 * @param fontFamily The font family.
 */
public void setFontFamily(String fontFamily) {
    COSString name = null;
    if (fontFamily != null) {
        name = new COSString(fontFamily);
    }
    dic.setItem(COSName.FONT_FAMILY, name);
}
Also used : COSString(com.tom_roush.pdfbox.cos.COSString)

Aggregations

COSString (com.tom_roush.pdfbox.cos.COSString)65 COSArray (com.tom_roush.pdfbox.cos.COSArray)33 COSBase (com.tom_roush.pdfbox.cos.COSBase)24 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)8 IOException (java.io.IOException)7 COSDictionary (com.tom_roush.pdfbox.cos.COSDictionary)5 COSName (com.tom_roush.pdfbox.cos.COSName)5 COSArrayList (com.tom_roush.pdfbox.pdmodel.common.COSArrayList)4 Map (java.util.Map)4 COSBoolean (com.tom_roush.pdfbox.cos.COSBoolean)2 COSFloat (com.tom_roush.pdfbox.cos.COSFloat)2 COSInteger (com.tom_roush.pdfbox.cos.COSInteger)2 PDResources (com.tom_roush.pdfbox.pdmodel.PDResources)2 MessageDigest (java.security.MessageDigest)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Operator (com.tom_roush.pdfbox.contentstream.operator.Operator)1