List of usage examples for org.apache.pdfbox.pdfwriter COSWriterXRefEntry COSWriterXRefEntry
public COSWriterXRefEntry(long start, COSBase obj, COSObjectKey keyValue)
From source file:com.aaasec.sigserv.csspsupport.pdfbox.modifications.CsCOSWriter.java
License:Apache License
/** * This will write a COS object./*from w w w . j av a 2s . c o m*/ * * @param obj The object to write. * * @throws COSVisitorException If there is an error visiting objects. */ public void doWriteObject(COSBase obj) throws COSVisitorException { try { writtenObjects.add(obj); if (obj instanceof COSDictionary) { COSDictionary dict = (COSDictionary) obj; COSName item = (COSName) dict.getItem(COSName.TYPE); if (COSName.SIG.equals(item) || COSName.DOC_TIME_STAMP.equals(item)) { reachedSignature = true; } } // find the physical reference currentObjectKey = getObjectKey(obj); // add a x ref entry addXRefEntry(new COSWriterXRefEntry(getStandardOutput().getPos(), obj, currentObjectKey)); // write the object getStandardOutput().write(String.valueOf(currentObjectKey.getNumber()).getBytes("ISO-8859-1")); getStandardOutput().write(SPACE); getStandardOutput().write(String.valueOf(currentObjectKey.getGeneration()).getBytes("ISO-8859-1")); getStandardOutput().write(SPACE); getStandardOutput().write(OBJ); getStandardOutput().writeEOL(); obj.accept(this); getStandardOutput().writeEOL(); getStandardOutput().write(ENDOBJ); getStandardOutput().writeEOL(); } catch (IOException e) { throw new COSVisitorException(e); } }