Example usage for org.apache.pdfbox.cos COSDictionary accept

List of usage examples for org.apache.pdfbox.cos COSDictionary accept

Introduction

In this page you can find the example usage for org.apache.pdfbox.cos COSDictionary accept.

Prototype

@Override
public Object accept(ICOSVisitor visitor) throws IOException 

Source Link

Document

visitor pattern double dispatch method.

Usage

From source file:com.aaasec.sigserv.csspsupport.pdfbox.modifications.CsCOSWriter.java

License:Apache License

/**
 * This will write the trailer to the PDF document.
 *
 * @param doc The document to create the trailer for.
 *
 * @throws IOException If there is an IOError while writing the document.
 * @throws COSVisitorException If there is an error while generating the
 * data./*from  w  w  w  .  j  ava2  s . co  m*/
 */
protected void doWriteTrailer(COSDocument doc) throws IOException, COSVisitorException {
    getStandardOutput().write(TRAILER);
    getStandardOutput().writeEOL();

    COSDictionary trailer = doc.getTrailer();
    //sort xref, needed only if object keys not regenerated
    Collections.sort(getXRefEntries());
    COSWriterXRefEntry lastEntry = getXRefEntries().get(getXRefEntries().size() - 1);
    trailer.setInt(COSName.SIZE, (int) lastEntry.getKey().getNumber() + 1);
    // Only need to stay, if an incremental update will be performed
    if (!incrementalUpdate) {
        trailer.removeItem(COSName.PREV);
    }
    // Remove a checksum if present
    trailer.removeItem(COSName.DOC_CHECKSUM);

    trailer.accept(this);
}