Table of Contents

Class PdfSplitter

Namespace
iText.Kernel.Utils
Assembly
itext.kernel.dll

Helper class to split the document based on some condition.

public class PdfSplitter
Inheritance
PdfSplitter
Inherited Members

Constructors

PdfSplitter(PdfDocument)

Creates a new instance of PdfSplitter class.

public PdfSplitter(PdfDocument pdfDocument)

Parameters

pdfDocument PdfDocument

the document to be split.

Methods

ExtractPageRange(PageRange)

Extracts the specified page ranges from a document.

public virtual PdfDocument ExtractPageRange(PageRange pageRange)

Parameters

pageRange PageRange

the page range to be extracted from the document.

Returns

PdfDocument

the resultant document containing the pages specified by the provided page range. Be warned that this document is not closed.

ExtractPageRanges(IList<PageRange>)

Extracts the specified page ranges from a document.

public virtual IList<PdfDocument> ExtractPageRanges(IList<PageRange> pageRanges)

Parameters

pageRanges IList<PageRange>

the list of page ranges for each of the resultant document.

Returns

IList<PdfDocument>

the list of the resultant documents for each of the specified page range. Be warned that these documents are not closed.

GetNextPdfWriter(PageRange)

This method is called when another split document is to be created.

protected virtual PdfWriter GetNextPdfWriter(PageRange documentPageRange)

Parameters

documentPageRange PageRange

the page range of the original document to be included in the document being created now.

Returns

PdfWriter

the PdfWriter instance for the document which is being created.

Remarks

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.

GetPdfDocument()

Gets the document to be split.

public virtual PdfDocument GetPdfDocument()

Returns

PdfDocument

PdfDocument to be split.

SetEventCountingMetaInfo(IMetaInfo)

Sets the iText.Commons.Actions.Contexts.IMetaInfo that will be used during PdfDocument creation.

public virtual void SetEventCountingMetaInfo(IMetaInfo metaInfo)

Parameters

metaInfo IMetaInfo

meta info to set

SetPreserveOutlines(bool)

If original document has outlines, then by default all resultant document will also have outlines.

public virtual void SetPreserveOutlines(bool preserveOutlines)

Parameters

preserveOutlines bool

defines whether the resultant documents will preserve outlines or not

Remarks

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.

SetPreserveTagged(bool)

If original document is tagged, then by default all resultant document will also be tagged.

public virtual void SetPreserveTagged(bool preserveTagged)

Parameters

preserveTagged bool

defines whether the resultant documents need to be tagged

Remarks

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.

SplitByOutlines(IList<string>)

Split a document by outline title (bookmark name), find outline by name and places the entire hierarchy in a separate document ( outlines and pages ) .

public virtual IList<PdfDocument> SplitByOutlines(IList<string> outlineTitles)

Parameters

outlineTitles IList<string>

list of outline titles .

Returns

IList<PdfDocument>

Collection of PdfDocument which contains split parts of a document

SplitByPageCount(int)

Splits a document into smaller documents with no more than @pageCount pages each.

public virtual IList<PdfDocument> SplitByPageCount(int pageCount)

Parameters

pageCount int

the biggest possible number of pages in a split document.

Returns

IList<PdfDocument>

the list of resultant documents. By warned that they are not closed.

SplitByPageCount(int, IDocumentReadyListener)

Splits a document into smaller documents with no more than @pageCount pages each.

public virtual void SplitByPageCount(int pageCount, PdfSplitter.IDocumentReadyListener documentReady)

Parameters

pageCount int

the biggest possible number of pages in a split document.

documentReady PdfSplitter.IDocumentReadyListener

the event listener which is called when another document is ready. You can close this document in this listener, for instance.

SplitByPageNumbers(IList<int>)

Splits the document by page numbers.

public virtual IList<PdfDocument> SplitByPageNumbers(IList<int> pageNumbers)

Parameters

pageNumbers IList<int>

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

IList<PdfDocument>

the list of resultant documents. By warned that they are not closed.

SplitByPageNumbers(IList<int>, IDocumentReadyListener)

Splits the document by page numbers.

public virtual void SplitByPageNumbers(IList<int> pageNumbers, PdfSplitter.IDocumentReadyListener documentReady)

Parameters

pageNumbers IList<int>

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 PdfSplitter.IDocumentReadyListener

the event listener which is called when another document is ready. You can close this document in this listener, for instance.

SplitBySize(long)

Splits the document basing on the given size specified in bytes.

public virtual IList<PdfDocument> SplitBySize(long size)

Parameters

size long

Preferred size specified in bytes for splitting.

Returns

IList<PdfDocument>

The documents which the source document was split into. Be warned that these documents are not closed.