Class COSDocumentWriter


  • public final class COSDocumentWriter
    extends java.lang.Object
    Serializes a whole COSDocument built up in memory (e.g. by com.pd4ml.pdf.merge) into a complete, self-contained PDF file: header, every registered indirect object, a classic xref table, and a trailer -- as opposed to COSWriter (one object's syntax only) or IncrementalUpdateWriter (an update appended to one specific original document's original bytes).

    The document's objects are expected to have been allocated with contiguous object numbers starting at 1 (which is what every allocator in COSObjectImporter guarantees); any gap is still handled (written as a free xref entry) but is not something this writer's own callers are expected to produce.

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] write​(COSDocument document)
      Writes document as a complete PDF file.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • write

        public static byte[] write​(COSDocument document)
                            throws COSException
        Writes document as a complete PDF file. document's trailer must already have a /Root entry pointing at an indirect (keyed) Catalog object.
        Throws:
        COSException