Method CopyRange
- Namespace
- BitMiracle.Docotic.Pdf
- Assembly
- BitMiracle.Docotic.Pdf.dll
CopyRange(int, int)
Copies a range of pages into a new PdfDocument.
public PdfDocument CopyRange(int index, int count)
Parameters
indexintThe zero-based starting index of the range of pages to copy.
countintThe number of pages to copy.
Returns
- PdfDocument
A new PdfDocument containing the copied pages.
Remarks
You become the owner of the returned PdfDocument and must dispose of it when finished working with it.
The new document is created using the default PdfConfigurationOptions. Use the CopyRange(int, int, PdfConfigurationOptions) overload to specify custom configuration options.
The original PdfDocument remains unchanged.
Consider calling RemoveUnusedResources() on the new document. This method can reduce file size when the copied pages reference unused resources such as fonts, images, or patterns.
This method can be used to split PDF documents. See the Split PDF documents in C# and VB.NET article for examples.
Use Extract or ExtractRange to extract pages from the current PdfDocument.
Exceptions
- ArgumentOutOfRangeException
Thrown when
indexis outside the bounds of the collection, whencountis less than or equal to0, or whenindex+countexceeds the number of pages in the document.
CopyRange(int, int, PdfConfigurationOptions)
Copies a range of pages into a new PdfDocument using the specified PdfConfigurationOptions.
public PdfDocument CopyRange(int index, int count, PdfConfigurationOptions options)
Parameters
indexintThe zero-based starting index of the range of pages to copy.
countintThe number of pages to copy.
optionsPdfConfigurationOptionsThe configuration options for the new document.
Returns
- PdfDocument
A new PdfDocument containing the copied pages.
Remarks
You become the owner of the returned PdfDocument and must dispose of it when finished working with it.
The new document is created using the specified options.
The original PdfDocument remains unchanged.
Consider calling RemoveUnusedResources() on the new document. This method can reduce file size when the copied pages reference unused resources such as fonts, images, or patterns.
This method can be used to split PDF documents. See the Split PDF documents in C# and VB.NET article for examples.
Use Extract or ExtractRange to extract pages from the current PdfDocument.
Exceptions
- ArgumentNullException
Thrown when
optionsisnull.- ArgumentOutOfRangeException
Thrown when
indexis outside the bounds of the collection, whencountis less than or equal to0, or whenindex+countexceeds the number of pages in the document.