Example usage for org.apache.pdfbox.cos COSName DOC_CHECKSUM

List of usage examples for org.apache.pdfbox.cos COSName DOC_CHECKSUM

Introduction

In this page you can find the example usage for org.apache.pdfbox.cos COSName DOC_CHECKSUM.

Prototype

COSName DOC_CHECKSUM

To view the source code for org.apache.pdfbox.cos COSName DOC_CHECKSUM.

Click Source Link

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 ww  w.jav  a 2  s . c o  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);
}