if (item != null && !COSName.XOBJECT.equals(entry.getKey())) item.setDirect(true); item.setDirect(true); subValue.accept( this ); value.accept(this); signatureLength = getStandardOutput().getPos()- signatureOffset; value.accept(this); byteRangeLength = getStandardOutput().getPos() - 1 - byteRangeOffset; reachedSignature = false; value.accept(this);
private int getHival(COSArray array) { int hival = ((COSNumber) array.getObject(2).getCOSObject()).intValue(); return Math.min(hival, 255); } }
return null; result.setDirect(false); parent.setItem(COSName.getPDFName(name), result);
/** * visitor pattern double dispatch method. * * @param visitor The object to notify when visiting this object. * @return any object, depending on the visitor implementation, or null * @throws IOException If an error occurs while visiting this object. */ @Override public Object accept( ICOSVisitor visitor ) throws IOException { return getObject() != null ? getObject().accept( visitor ) : COSNull.NULL.accept( visitor ); }
@Override public Boolean getisAssociatedFile() { return Boolean.valueOf(this.baseObject != null && StaticContainers.fileSpecificationKeys.contains(this.baseObject.getKey())); }
private void parseCOSDictionaryNameValuePair(COSDictionary obj) throws IOException { COSName key = parseCOSName(); COSBase value = parseCOSDictionaryValue(); skipSpaces(); if (((char) seqSource.peek()) == 'd') { // if the next string is 'def' then we are parsing a cmap stream // and want to ignore it, otherwise throw an exception. String potentialDEF = readString(); if (!potentialDEF.equals(DEF)) { seqSource.unread(potentialDEF.getBytes(ISO_8859_1)); } else { skipSpaces(); } } if (value == null) { LOG.warn("Bad dictionary declaration at offset " + seqSource.getPosition()); } else { // label this item as direct, to avoid signature problems. value.setDirect(true); obj.setItem(key, value); } }
obj.accept( this );
private static void addElementKey(COSBase element) { COSBase base = element; while (base instanceof COSObject) { base = ((COSObject) base).getObject(); } if (base != null) { COSObjectKey key = base.getKey(); if (key != null) { StaticContainers.fileSpecificationKeys.add(key); } } }
if (item != null && !COSName.XOBJECT.equals(entry.getKey())) item.setDirect(true); item.setDirect(true); subValue.accept( this ); value.accept(this); signatureLength = getStandardOutput().getPos()- signatureOffset; value.accept(this); byteRangeLength = getStandardOutput().getPos() - 1 - byteRangeOffset; reachedSignature = false; value.accept(this);
/** * 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)); } }
private static byte[] getBytesFromPacket(final COSArray cosArray) throws IOException { try (final ByteArrayOutputStream baos = new ByteArrayOutputStream()) { for (int i = 1; i < cosArray.size(); i += 2) { COSBase cosObj = cosArray.getObject(i); if (cosObj instanceof COSStream) { baos.write(getBytesFromStream((COSStream) cosObj.getCOSObject())); } } return baos.toByteArray(); } }
/** * Transform object of pdf box to corresponding object of abstract model * implementation. For transforming using {@code PBCosVisitor}. * * @param base * the base object that all objects in the PDF document will * extend in pdf box * @return object of abstract model implementation, transformed from * {@code base} */ public static CosObject getFromValue(COSBase base, PDDocument document, PDFAFlavour flavour) { try { if (base != null) { PBCosVisitor visitor = PBCosVisitor.getInstance(document, flavour); if (base instanceof COSObject) { return (CosObject) PBCosVisitor .visitFromObject((COSObject) base, document, flavour); } return (CosObject) base.accept(visitor); } } catch (IOException e) { LOGGER.debug( "Problems with wrapping pdfbox object \"" + base.toString() + "\". " + e.getMessage(), e); } return null; } }
protected PBoxPDObject(PDFontLike pdFontLike, final String type) { super(type); this.pdFontLike = pdFontLike; if (pdFontLike instanceof COSBase) { COSObjectKey key = ((COSBase) pdFontLike).getKey(); id = key != null ? key.getNumber() + " " + key.getGeneration() + " obj " + this.getObjectType() : super.getID(); } }
if (item != null && !COSName.XOBJECT.equals(entry.getKey())) item.setDirect(true); item.setDirect(true); subValue.accept( this ); value.accept(this); signatureLength = getStandardOutput().getPos()- signatureOffset; value.accept(this); byteRangeLength = getStandardOutput().getPos() - 1 - byteRangeOffset; reachedSignature = false; value.accept(this);
dictionaryObject.setDirect(true);
if (kid instanceof COSDictionary) if (kid.getCOSObject() == this.getCOSObject())
/** * visitor pattern double dispatch method. * * @param visitor The object to notify when visiting this object. * @return any object, depending on the visitor implementation, or null * @throws IOException If an error occurs while visiting this object. */ @Override public Object accept( ICOSVisitor visitor ) throws IOException { return getObject() != null ? getObject().accept( visitor ) : COSNull.NULL.accept( visitor ); }