/** * Returns the annotations appearance state, which selects the applicable appearance stream from an appearance * subdictionary. */ public COSName getAppearanceState() { return getCOSObject().getCOSName(COSName.AS); }
/** * Tell if the dictionary is a PDF catalog. Override this for an FDF catalog. * * @param dictionary * @return true if the given dictionary is a root dictionary */ protected boolean isCatalog(COSDictionary dictionary) { return COSName.CATALOG.equals(dictionary.getCOSName(COSName.TYPE)); }
/** * Returns true if the node is a page tree node (i.e. and intermediate). */ private boolean isPageTreeNode(COSDictionary node ) { // some files such as PDFBOX-2250-229205.pdf don't have Pages set as the Type, so we have // to check for the presence of Kids too return node != null && (node.getCOSName(COSName.TYPE) == COSName.PAGES || node.containsKey(COSName.KIDS)); }
private boolean isCIDFont(COSDictionary dic) { return dic.containsKey(COSName.SUBTYPE) && (dic.getCOSName(COSName.SUBTYPE).equals(COSName.CID_FONT_TYPE0) || dic.getCOSName(COSName.SUBTYPE).equals(COSName.CID_FONT_TYPE2)); }
private static void sanitizeType(COSDictionary dictionary) { COSName type = dictionary.getCOSName(COSName.TYPE); if (type == null) { dictionary.setItem(COSName.TYPE, COSName.PAGE); return; } if (!COSName.PAGE.equals(type)) { throw new IllegalStateException("Expected 'Page' but found " + type); } }
private boolean isImageStream(COSDictionary dic, boolean isThumb) { if (isThumb) { return true; } return dic.containsKey(COSName.SUBTYPE) && dic.getCOSName(COSName.SUBTYPE).equals(COSName.IMAGE); }
if (COSName.ANNOT.equals(dict.getCOSName(COSName.TYPE)) && COSName.WIDGET.equals(dict.getCOSName(COSName.SUBTYPE)) || dict.containsKey(COSName.T) && dict.containsKey(COSName.KIDS)) COSName type = dict.getCOSName(COSName.TYPE); if (type != null) COSName subtype = dict.getCOSName(COSName.SUBTYPE); if (subtype != null)
private boolean isAnnot(Object obj) { Object underneathObject = getUnderneathObject(obj); return underneathObject instanceof COSDictionary && ((COSDictionary) underneathObject).containsKey(COSName.TYPE) && ((COSDictionary) underneathObject).getCOSName(COSName.TYPE).equals(COSName.ANNOT); }
private boolean isFontDescriptor(Object obj) { Object underneathObject = getUnderneathObject(obj); return underneathObject instanceof COSDictionary && ((COSDictionary) underneathObject).containsKey(COSName.TYPE) && ((COSDictionary) underneathObject).getCOSName(COSName.TYPE).equals(COSName.FONT_DESC); }
private boolean isXmlMetadataStream(COSDictionary dic) { return dic.containsKey(COSName.SUBTYPE) && dic.getCOSName(COSName.SUBTYPE).equals(COSName.getPDFName("XML")); } }
if (hasBaseEncoding) COSName name = encoding.getCOSName(COSName.BASE_ENCODING);
/** * Creates a new PDCIDFont instance with the appropriate subclass. * * @param dictionary descendant font dictionary * @return a PDCIDFont instance, based on the SubType entry of the dictionary * @throws IOException if something goes wrong */ static PDCIDFont createDescendantFont(COSDictionary dictionary, PDType0Font parent) throws IOException { COSName type = dictionary.getCOSName(COSName.TYPE, COSName.FONT); if (!COSName.FONT.equals(type)) { throw new IllegalArgumentException("Expected 'Font' dictionary but found '" + type.getName() + "'"); } COSName subType = dictionary.getCOSName(COSName.SUBTYPE); if (COSName.CID_FONT_TYPE0.equals(subType)) { return new PDCIDFontType0(dictionary, parent); } else if (COSName.CID_FONT_TYPE2.equals(subType)) { return new PDCIDFontType2(dictionary, parent); } else { throw new IOException("Invalid font type: " + type); } }
@Override String getFlagType() { COSName fieldType = dictionary.getCOSName(COSName.FT); if (COSName.TX.equals(fieldType)) { return "Text field flag"; } else if (COSName.BTN.equals(fieldType)) { return "Button field flag"; } else if (COSName.CH.equals(fieldType)) { return "Choice field flag"; } return null; }
private boolean isFont(Object selectedNode) { selectedNode = getUnderneathObject(selectedNode); if (selectedNode instanceof COSDictionary) { COSDictionary dic = (COSDictionary)selectedNode; return dic.containsKey(COSName.TYPE) && dic.getCOSName(COSName.TYPE).equals(COSName.FONT) && !isCIDFont(dic); } return false; }
/** * @return The parent of this node or null if there is no parent. */ PDOutlineNode getParent() { COSBase base = getCOSObject().getDictionaryObject(COSName.PARENT); if (base instanceof COSDictionary) { COSDictionary parent = (COSDictionary) base; if (COSName.OUTLINES.equals(parent.getCOSName(COSName.TYPE))) { return new PDDocumentOutline(parent); } return new PDOutlineItem(parent); } return null; }
COSName type = kidDictionary.getCOSName(COSName.TYPE); if (COSName.PAGES.equals(type))
/** * Constructor for reading. * * @param root A page tree root. * @param document The document which contains "root". */ PDPageTree(COSDictionary root, PDDocument document) { if (root == null) { throw new IllegalArgumentException("page tree root cannot be null"); } // repair bad PDFs which contain a Page dict instead of a page tree, see PDFBOX-3154 if (COSName.PAGE.equals(root.getCOSName(COSName.TYPE))) { COSArray kids = new COSArray(); kids.add(root); this.root = new COSDictionary(); this.root.setItem(COSName.KIDS, kids); this.root.setInt(COSName.COUNT, 1); } else { this.root = root; } this.document = document; }
if (group != null && COSName.TRANSPARENCY.equals(group.getCOSName(COSName.S)))
@Override Object[][] getFlagBits() { int flagValue = dictionary.getInt(COSName.FF); COSName fieldType = dictionary.getCOSName(COSName.FT); if (COSName.TX.equals(fieldType)) { return getTextFieldFlagBits(flagValue); } else if (COSName.BTN.equals(fieldType)) { return getButtonFieldFlagBits(flagValue); } else if (COSName.CH.equals(fieldType)) { return getChoiceFieldFlagBits(flagValue); } return null; }
COSName name = dict.getCOSName(COSName.ENCODING); if (isCMapPredefined && !(name == COSName.IDENTITY_H || name == COSName.IDENTITY_V) || isDescendantCJK)