List of usage examples for org.apache.pdfbox.cos COSDictionary getLong
public long getLong(COSName key)
From source file:com.aaasec.sigserv.csspsupport.pdfbox.modifications.CsCOSWriter.java
License:Apache License
/** * The visit from document method./*from w ww . j a v a 2 s . c o m*/ * * @param doc The object that is being visited. * * @throws COSVisitorException If there is an exception while visiting this * object. * * @return null */ public Object visitFromDocument(COSDocument doc) throws COSVisitorException { try { if (!incrementalUpdate) { doWriteHeader(doc); } doWriteBody(doc); // get the previous trailer COSDictionary trailer = doc.getTrailer(); long hybridPrev = -1; if (trailer != null) { hybridPrev = trailer.getLong(COSName.XREF_STM); } if (incrementalUpdate) { doWriteXRefInc(doc, hybridPrev); } else { doWriteXRef(doc); } // the trailer section should only be used for xref tables not for xref streams if (!incrementalUpdate || !doc.isXRefStream() || hybridPrev != -1) { doWriteTrailer(doc); } // write endof getStandardOutput().write(STARTXREF); getStandardOutput().writeEOL(); getStandardOutput().write(String.valueOf(getStartxref()).getBytes("ISO-8859-1")); getStandardOutput().writeEOL(); getStandardOutput().write(EOF); getStandardOutput().writeEOL(); if (incrementalUpdate) { doWriteSignature(doc); } return null; } catch (IOException e) { throw new COSVisitorException(e); } catch (SignatureException e) { throw new COSVisitorException(e); } }