Class PdfConcatenate


  • public class PdfConcatenate
    extends java.lang.Object
    Wrapper class for PdfCopy and PdfSmartCopy. Allows you to concatenate existing PDF documents with much less code.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected PdfCopy copy
      The actual PdfWriter
      protected Document document
      The Document object for PdfCopy.
    • Constructor Summary

      Constructors 
      Constructor Description
      PdfConcatenate​(java.io.OutputStream os)
      Creates an instance of the concatenation class.
      PdfConcatenate​(java.io.OutputStream os, boolean smart)
      Creates an instance of the concatenation class.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int addPages​(PdfReader reader)
      Adds the pages from an existing PDF document.
      void close()
      We've finished writing the concatenated document.
      PdfCopy getWriter()
      Gets the PdfCopy instance so that you can add bookmarks or change preferences before you close PdfConcatenate.
      void open()
      Opens the document (if it isn't open already).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • document

        protected Document document
        The Document object for PdfCopy.
      • copy

        protected PdfCopy copy
        The actual PdfWriter
    • Constructor Detail

      • PdfConcatenate

        public PdfConcatenate​(java.io.OutputStream os)
                       throws DocumentException
        Creates an instance of the concatenation class.
        Parameters:
        os - the OutputStream for the PDF document
        Throws:
        DocumentException
      • PdfConcatenate

        public PdfConcatenate​(java.io.OutputStream os,
                              boolean smart)
                       throws DocumentException
        Creates an instance of the concatenation class.
        Parameters:
        os - the OutputStream for the PDF document
        smart - do we want PdfCopy to detect redundant content?
        Throws:
        DocumentException
    • Method Detail

      • addPages

        public int addPages​(PdfReader reader)
                     throws DocumentException,
                            java.io.IOException
        Adds the pages from an existing PDF document.
        Parameters:
        reader - the reader for the existing PDF document
        Returns:
        the number of pages that were added
        Throws:
        DocumentException
        java.io.IOException
      • getWriter

        public PdfCopy getWriter()
        Gets the PdfCopy instance so that you can add bookmarks or change preferences before you close PdfConcatenate.
      • open

        public void open()
        Opens the document (if it isn't open already). Opening the document is done implicitly.
      • close

        public void close()
        We've finished writing the concatenated document.