Class PdfSplitter

java.lang.Object
com.itextpdf.kernel.utils.PdfSplitter

public class PdfSplitter extends Object
  • Constructor Details

    • PdfSplitter

      public PdfSplitter (PdfDocument pdfDocument)
      Creates a new instance of PdfSplitter class.
      Parameters:
      pdfDocument - the document to be split.
  • Method Details

    • setEventCountingMetaInfo

      public void setEventCountingMetaInfo (IMetaInfo metaInfo)
      Sets the IMetaInfo that will be used during PdfDocument creation.
      Parameters:
      metaInfo - meta info to set
    • setPreserveTagged

      public void setPreserveTagged (boolean preserveTagged)
      If original document is tagged, then by default all resultant document will also be tagged. This could be changed with this flag - if set to false, resultant documents will be not tagged, even if original document is tagged.
      Parameters:
      preserveTagged - defines whether the resultant documents need to be tagged
    • setPreserveOutlines

      public void setPreserveOutlines (boolean preserveOutlines)
      If original document has outlines, then by default all resultant document will also have outlines. This could be changed with this flag - if set to false, resultant documents won't contain outlines, even if original document had them.
      Parameters:
      preserveOutlines - defines whether the resultant documents will preserve outlines or not
    • splitBySize

      public List<PdfDocument> splitBySize (long size)
      Splits the document basing on the given size specified in bytes.
      Parameters:
      size - Preferred size specified in bytes for splitting.
      Returns:
      The documents which the source document was split into. Be warned that these documents are not closed.
    • splitByPageNumbers

      public void splitByPageNumbers (List<Integer> pageNumbers, PdfSplitter.IDocumentReadyListener documentReady)
      Splits the document by page numbers.
      Parameters:
      pageNumbers - the numbers of pages from which another document is to be started. If the first element is not 1, then 1 is implied (i.e. the first split document will start from page 1 in any case).
      documentReady - the event listener which is called when another document is ready. You can close this document in this listener, for instance.
    • splitByPageNumbers

      public List<PdfDocument> splitByPageNumbers (List<Integer> pageNumbers)
      Splits the document by page numbers.
      Parameters:
      pageNumbers - the numbers of pages from which another document is to be started. If the first element is not 1, then 1 is implied (i.e. the first split document will start from page 1 in any case).
      Returns:
      the list of resultant documents. By warned that they are not closed.
    • splitByPageCount

      public void splitByPageCount (int pageCount, PdfSplitter.IDocumentReadyListener documentReady)
      Splits a document into smaller documents with no more than @pageCount pages each.
      Parameters:
      pageCount - the biggest possible number of pages in a split document.
      documentReady - the event listener which is called when another document is ready. You can close this document in this listener, for instance.
    • splitByPageCount

      public List<PdfDocument> splitByPageCount (int pageCount)
      Splits a document into smaller documents with no more than @pageCount pages each.
      Parameters:
      pageCount - the biggest possible number of pages in a split document.
      Returns:
      the list of resultant documents. By warned that they are not closed.
    • extractPageRanges

      public List<PdfDocument> extractPageRanges (List<PageRange> pageRanges)
      Extracts the specified page ranges from a document.
      Parameters:
      pageRanges - the list of page ranges for each of the resultant document.
      Returns:
      the list of the resultant documents for each of the specified page range. Be warned that these documents are not closed.
    • extractPageRange

      public PdfDocument extractPageRange (PageRange pageRange)
      Extracts the specified page ranges from a document.
      Parameters:
      pageRange - the page range to be extracted from the document.
      Returns:
      the resultant document containing the pages specified by the provided page range. Be warned that this document is not closed.
    • getPdfDocument

      public PdfDocument getPdfDocument()
    • getNextPdfWriter

      protected PdfWriter getNextPdfWriter (PageRange documentPageRange)
      This method is called when another split document is to be created. You can override this method and return your own PdfWriter depending on your needs.
      Parameters:
      documentPageRange - the page range of the original document to be included in the document being created now.
      Returns:
      the PdfWriter instance for the document which is being created.
    • splitByOutlines

      public List<PdfDocument> splitByOutlines (List<String> outlineTitles)
      Split a document by outline title (bookmark name), find outline by name and places the entire hierarchy in a separate document ( outlines and pages ) .
      Parameters:
      outlineTitles - list of outline titles .
      Returns:
      Collection of PdfDocument which contains split parts of a document