Search in sources :

Example 86 with COSDictionary

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

the class PDFontDescriptor method getPanose.

/**
 * Returns the Panose entry of the Style dictionary, if any.
 *
 * @return A Panose wrapper object.
 */
public PDPanose getPanose() {
    COSDictionary style = (COSDictionary) dic.getDictionaryObject(COSName.STYLE);
    if (style != null) {
        COSString panose = (COSString) style.getDictionaryObject(COSName.PANOSE);
        byte[] bytes = panose.getBytes();
        return new PDPanose(bytes);
    }
    return null;
}
Also used : COSDictionary(com.tom_roush.pdfbox.cos.COSDictionary) COSString(com.tom_roush.pdfbox.cos.COSString)

Example 87 with COSDictionary

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

the class FDFTemplate method getTemplateReference.

/**
 * This is the template reference.
 *
 * @return The template reference.
 */
public FDFNamedPageReference getTemplateReference() {
    FDFNamedPageReference retval = null;
    COSDictionary dict = (COSDictionary) template.getDictionaryObject(COSName.TREF);
    if (dict != null) {
        retval = new FDFNamedPageReference(dict);
    }
    return retval;
}
Also used : COSDictionary(com.tom_roush.pdfbox.cos.COSDictionary)

Example 88 with COSDictionary

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

the class MergeAcroFormsTest method compareFieldProperties.

private void compareFieldProperties(PDField sourceField, PDField toBeComapredField) {
    // List of keys for comparison
    // Don't include too complex properties such as AP as this will fail the test because
    // of a stack overflow when
    final String[] keys = { "FT", "T", "TU", "TM", "Ff", "V", "DV", "Opts", "TI", "I", "Rect", "DA" };
    COSDictionary sourceFieldCos = sourceField.getCOSObject();
    COSDictionary toBeComparedCos = toBeComapredField.getCOSObject();
    for (String key : keys) {
        COSBase sourceBase = sourceFieldCos.getDictionaryObject(key);
        COSBase toBeComparedBase = toBeComparedCos.getDictionaryObject(key);
        if (sourceBase != null) {
            assertEquals("The content of the field properties shall be the same", sourceBase.toString(), toBeComparedBase.toString());
        } else {
            assertNull("If the source property is null the compared property shall be null too", toBeComparedBase);
        }
    }
}
Also used : COSDictionary(com.tom_roush.pdfbox.cos.COSDictionary) COSBase(com.tom_roush.pdfbox.cos.COSBase)

Example 89 with COSDictionary

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

the class PDStructureTreeRoot method setRoleMap.

/**
 * Sets the role map.
 *
 * @param roleMap the role map
 */
public void setRoleMap(Map<String, String> roleMap) {
    COSDictionary rmDic = new COSDictionary();
    for (Map.Entry<String, String> entry : roleMap.entrySet()) {
        rmDic.setName(entry.getKey(), entry.getValue());
    }
    this.getCOSObject().setItem(COSName.ROLE_MAP, rmDic);
}
Also used : COSDictionary(com.tom_roush.pdfbox.cos.COSDictionary) Map(java.util.Map) HashMap(java.util.HashMap) COSDictionaryMap(com.tom_roush.pdfbox.pdmodel.common.COSDictionaryMap)

Example 90 with COSDictionary

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

the class PDUserAttributeObject method getOwnerUserProperties.

/**
 * Returns the user properties.
 *
 * @return the user properties
 */
public List<PDUserProperty> getOwnerUserProperties() {
    COSArray p = (COSArray) this.getCOSObject().getDictionaryObject(COSName.P);
    List<PDUserProperty> properties = new ArrayList<PDUserProperty>(p.size());
    for (int i = 0; i < p.size(); i++) {
        properties.add(new PDUserProperty((COSDictionary) p.getObject(i), this));
    }
    return properties;
}
Also used : COSArray(com.tom_roush.pdfbox.cos.COSArray) COSDictionary(com.tom_roush.pdfbox.cos.COSDictionary) ArrayList(java.util.ArrayList)

Aggregations

COSDictionary (com.tom_roush.pdfbox.cos.COSDictionary)221 COSArray (com.tom_roush.pdfbox.cos.COSArray)68 COSBase (com.tom_roush.pdfbox.cos.COSBase)68 IOException (java.io.IOException)25 ArrayList (java.util.ArrayList)24 COSName (com.tom_roush.pdfbox.cos.COSName)23 COSObject (com.tom_roush.pdfbox.cos.COSObject)22 COSArrayList (com.tom_roush.pdfbox.pdmodel.common.COSArrayList)15 HashMap (java.util.HashMap)14 COSStream (com.tom_roush.pdfbox.cos.COSStream)13 Map (java.util.Map)12 PDPage (com.tom_roush.pdfbox.pdmodel.PDPage)10 COSString (com.tom_roush.pdfbox.cos.COSString)7 PDDocument (com.tom_roush.pdfbox.pdmodel.PDDocument)6 PDResources (com.tom_roush.pdfbox.pdmodel.PDResources)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 List (java.util.List)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 File (java.io.File)5 Test (org.junit.Test)5