Refine search
@Override public String getName() { return COSName.DEVICERGB.getName(); }
/** * This will set the line ending style for the end point, see the LE_ constants for the possible values. * * @param style The new style. */ public void setEndPointEndingStyle(String style) { String actualStyle = style == null ? PDAnnotationLine.LE_NONE : style; COSArray array = (COSArray) annot.getDictionaryObject(COSName.LE); if (array == null) { array = new COSArray(); array.add(COSName.getPDFName(PDAnnotationLine.LE_NONE)); array.add(COSName.getPDFName(actualStyle)); annot.setItem(COSName.LE, array); } else { array.setName(1, actualStyle); } }
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 boolean isXmlMetadataStream(COSDictionary dic) { return dic.containsKey(COSName.SUBTYPE) && dic.getCOSName(COSName.SUBTYPE).equals(COSName.getPDFName("XML")); } }
/** * Set the relationship between the current document and the target (which may be an * intermediate target). * * @param relationship Valid values are P (the target is the parent of the current document) and * C (the target is a child of the current document). * * throws IllegalArgumentException if the parameter is not P or C. */ public void setRelationship(COSName relationship) { if (!COSName.P.equals(relationship) && !COSName.C.equals(relationship)) { throw new IllegalArgumentException("The only valid are P or C, not " + relationship.getName()); } dict.setItem(COSName.R, relationship); }
COSBase c = this.getCOSObject().getDictionaryObject(key); COSName name = COSName.getPDFName(className); if (c instanceof COSArray) array.remove(name); if ((array.size() == 2) && (array.getInt(1) == 0)) this.getCOSObject().setItem(key, array.getObject(0)); if (name.equals(directC)) this.getCOSObject().setItem(key, null);
/** * Gets an array of strings. * * @param name the attribute name * @return the array of strings */ protected String[] getArrayOfString(String name) { COSBase v = this.getCOSObject().getDictionaryObject(name); if (v instanceof COSArray) { COSArray array = (COSArray) v; String[] strings = new String[array.size()]; for (int i = 0; i < array.size(); i++) { strings[i] = ((COSName) array.getObject(i)).getName(); } return strings; } return null; }
/** * 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; }
/** * Indicates the operating system. The string format isn't specified yet. Value will be stored * as first item of the array, as specified in PDF Signature Build Dictionary Specification for * PDF v1.7. * * @param os is a string with the system id or name. */ public void setOS(String os) { if (os == null) { dictionary.removeItem(COSName.OS); } else { COSBase osArray = dictionary.getItem(COSName.OS); if (!(osArray instanceof COSArray)) { osArray = new COSArray(); osArray.setDirect(true); dictionary.setItem(COSName.OS, osArray); } ((COSArray) osArray).add(0, COSName.getPDFName(os)); } }
/** * Returns list of maps that contains subject distinguished names like [(cn: John Doe, o: Doe), * (cn: John Smith)] both keys are typically of the form 'cn', 'o', 'email', '2.5.4.43'; and * values are text strings. */ public List<Map<String, String>> getSubjectDN() { COSBase base = this.dictionary.getDictionaryObject(COSName.SUBJECT_DN); if (base instanceof COSArray) { COSArray cosArray = (COSArray) base; List subjectDNList = cosArray.toList(); List<Map<String, String>> result = new LinkedList<>(); for (Object subjectDNItem : subjectDNList) { if (subjectDNItem instanceof COSDictionary) { COSDictionary subjectDNItemDict = (COSDictionary) subjectDNItem; Map<String, String> subjectDNMap = new HashMap<>(); for (COSName key : subjectDNItemDict.keySet()) { subjectDNMap.put(key.getName(), subjectDNItemDict.getString(key)); } result.add(subjectDNMap); } } return result; } return null; }
((COSName)o).writePDF( output ); output.write( SPACE ); for( int i=0; i<array.size(); i++ ) writeObject( array.get( i ) ); output.write( SPACE ); for (Map.Entry<COSName, COSBase> entry : obj.entrySet()) for( COSName key : dic.keySet() ) Object value = dic.getDictionaryObject( key ); key.writePDF( output ); output.write( SPACE ); writeObject( value );
@Override protected void encode(InputStream input, OutputStream encoded, COSDictionary parameters) throws IOException { COSName encryptionName = (COSName) parameters.getDictionaryObject(COSName.NAME); if(encryptionName == null || encryptionName.equals(COSName.IDENTITY)) { // currently the only supported implementation is the Identity crypt filter Filter identityFilter = new IdentityFilter(); identityFilter.encode(input, encoded, parameters); } else { throw new IOException("Unsupported crypt filter " + encryptionName.getName()); } } }
private PDColorSpace createColorSpace(COSBase cs) throws IOException { if (cs instanceof COSName) { return PDColorSpace.create(toLongName(cs), resources); } if (cs instanceof COSArray && ((COSArray) cs).size() > 1) { COSArray srcArray = (COSArray) cs; COSBase csType = srcArray.get(0); if (COSName.I.equals(csType) || COSName.INDEXED.equals(csType)) { COSArray dstArray = new COSArray(); dstArray.addAll(srcArray); dstArray.set(0, COSName.INDEXED); dstArray.set(1, toLongName(srcArray.get(1))); return PDColorSpace.create(dstArray, resources); } throw new IOException("Illegal type of inline image color space: " + csType); } throw new IOException("Illegal type of object for inline image color space: " + cs); }
@Override public void createProcSetArray() { COSArray procSetArr = new COSArray(); procSetArr.add(COSName.getPDFName("PDF")); procSetArr.add(COSName.getPDFName("Text")); procSetArr.add(COSName.getPDFName("ImageB")); procSetArr.add(COSName.getPDFName("ImageC")); procSetArr.add(COSName.getPDFName("ImageI")); pdfStructure.setProcSet(procSetArr); LOG.info("ProcSet array has been created"); }
String subtype = stream.getNameAsString(COSName.SUBTYPE); if (COSName.IMAGE.getName().equals(subtype)) else if (COSName.FORM.getName().equals(subtype)) ResourceCache cache = resources != null ? resources.getResourceCache() : null; COSDictionary group = (COSDictionary)stream.getDictionaryObject(COSName.GROUP); if (group != null && COSName.TRANSPARENCY.equals(group.getCOSName(COSName.S))) else if (COSName.PS.getName().equals(subtype))
/** * Creates a new Pattern dictionary. */ public PDAbstractPattern() { patternDictionary = new COSDictionary(); patternDictionary.setName(COSName.TYPE, COSName.PATTERN.getName()); }
protected void validateXObjects(PreflightContext context, PDResources resources) throws ValidationException COSDictionary mapOfXObj = COSUtils.getAsDictionary(resources.getCOSObject().getItem(COSName.XOBJECT), cosDocument); if (mapOfXObj != null) for (Entry<COSName, COSBase> entry : mapOfXObj.entrySet()) + entry.getKey().getName() + "'", e));
/** * This will set an item in the dictionary. If value is null then the result will be the same as removeItem( key ). * * @param key The key to the dictionary object. * @param value The value to the dictionary object. */ public void setItem(String key, COSObjectable value) { setItem(COSName.getPDFName(key), value); }
private void initUI(String fontReferenceName, PDResources resources) { PDFont font = null; for (COSName name: resources.getFontNames()) { if (name.getName().equals(fontReferenceName)) { try { font = resources.getFont(name); } catch (IOException e) { e.printStackTrace(); } } } if (font != null) { markup = "<html>" + font.getName() + "</html>"; } }