PdfFileEditor

PdfFileEditor

Overview

PdfFileEditor is a class in Aspose.PDF FOSS for .NET.

Facade for common PDF file editing operations: concatenate, split, extract, delete pages.

This class declares 118 methods for PdfFileEditor objects in .NET programs. Available methods include: AddMargins, AddMarginsPct, AddPageBreak, Append, Concatenate, Delete, Extract, Insert, MakeBooklet, MakeNUp, PdfFileEditor, ResizeContents, and 16 additional methods. Public members are accessible to any .NET application after installing the Aspose.PDF FOSS for .NET package. Properties: AllowConcatenateExceptions, AllowExceptions, CloseConcatenatedStreams, ConcatenationPacketSize, ConversionLog, ConvertTo, and 19 more.

Properties

NameTypeAccessDescription
AllowExceptionsboolRead/WriteWhen true, Try* methods propagate exceptions; when false (the default) they capture the exception in LastException and return false.
LastExceptionException?ReadLast exception captured by a Try* method, or null.
RemoveSignaturesboolRead/WriteWhen true, signatures present in the inputs are stripped from the Concatenate output.
OwnerPasswordstringRead/WriteWhen non-empty, Concatenate outputs are encrypted with this owner password (AES-128) after the merge completes.
KeepActionsboolRead/WriteWhen true, Concatenate honours document-level /AA actions on the inputs and copies them onto the output catalog.
MergeDuplicateLayersboolRead/WriteWhen true, identical optional-content groups in the inputs are deduplicated in the Concatenate output.
PreserveUserRightsboolRead/WriteWhen true, the Concatenate output retains /UR usage-rights entries from the inputs.
UniqueSuffixstringRead/WriteSuffix template used to disambiguate colliding form-field names when KeepFieldsUnique is true.
ConversionLogstringReadDiagnostic log emitted by the most recent Concatenate / ConvertTo pass.
ConvertToPdfFormatRead/WriteTarget PDF/A format for the next Concatenate output.
CorruptedItemsCorruptedItem[]ReadItems the Concatenate path skipped over because their input failed to parse.
CorruptedFileActionConcatenateCorruptedFileActionRead/WriteMirrors PdfFileEditor.CorruptedFileAction.
CloseConcatenatedStreamsboolRead/WriteWhen true, the stream-based Concatenate / Append / Insert overloads dispose the input streams (and the output stream after writing) once the operation completes.
CopyLogicalStructureboolRead/WriteMirrors PdfFileEditor.CopyLogicalStructure.
CopyOutlinesboolRead/WriteMirrors PdfFileEditor.CopyOutlines.
KeepFieldsUniqueboolRead/WriteWhen true, Concatenate renames colliding form-field names in the inputs so the output has unique field names.
MergeDuplicateOutlinesboolRead/WriteWhen true, identical outline entries from the inputs are merged in the output instead of duplicated.
AllowConcatenateExceptionsboolRead/WriteObsolete property kept for API compatibility.
IncrementalUpdatesboolRead/WriteWhen true, Concatenate appends pages to the destination using PDF incremental updates instead of rewriting the entire file.
OptimizeSizeboolRead/WriteWhen true, Concatenate runs an optimization pass on the output before saving.
ConcatenationPacketSizeintRead/WriteBuffer-size hint (bytes) used by streaming Concatenate implementations.
UseDiskBufferboolRead/WriteWhen true, Concatenate buffers intermediate pages on disk instead of in memory.
E_EMPTY_PAGE_RANGEstringReadError message for null/empty page ranges.
E_SMALL_PAGE_RANGEstringReadError message for a page range with fewer than 2 elements.
E_WRONG_PAGE_RANGEstringReadError message for a page range where start > end.

Methods

SignatureDescription
TryAppend(inputFile: string, portFiles: string[], startPage: int, endPage: int, outputFile: string)Calls TryAppend(inputFile, portFiles, startPage, endPage, outputFile) on this PdfFileEditor instance.
TryAppend(inputStream: Stream, portStreams: Stream[], startPage: int, endPage: int, outputStream: Stream)Calls TryAppend(inputStream, portStreams, startPage, endPage, outputStream) on this PdfFileEditor instance.
TryConcatenate(inputFiles: string[], outputFile: string)Calls TryConcatenate(inputFiles, outputFile) on this PdfFileEditor instance.
TryConcatenate(firstInputFile: string, secInputFile: string, outputFile: string)Calls TryConcatenate(firstInputFile, secInputFile, outputFile) on this PdfFileEditor instance.
TryConcatenate(firstInputFile: string, secInputFile: string, blankPageFile: string, outputFile: string)Calls TryConcatenate(firstInputFile, secInputFile, blankPageFile, outputFile) on this PdfFileEditor instance.
TryConcatenate(inputStream: Stream[], outputStream: Stream)Calls TryConcatenate(inputStream, outputStream) on this PdfFileEditor instance.
TryConcatenate(firstInputStream: Stream, secInputStream: Stream, blankPageStream: Stream, outputStream: Stream)Calls TryConcatenate(firstInputStream, secInputStream, blankPageStream, outputStream) on this PdfFileEditor instance.
TryConcatenate(src: Document[], dest: Document)Calls TryConcatenate(src, dest) on this PdfFileEditor instance.
TryDelete(inputFile: string, pageNumber: int[], outputFile: string)Calls TryDelete(inputFile, pageNumber, outputFile) on this PdfFileEditor instance.
TryDelete(inputStream: Stream, pageNumber: int[], outputStream: Stream)Calls TryDelete(inputStream, pageNumber, outputStream) on this PdfFileEditor instance.
TryExtract(inputFile: string, startPage: int, endPage: int, outputFile: string)Calls TryExtract(inputFile, startPage, endPage, outputFile) on this PdfFileEditor instance.
TryExtract(inputFile: string, pageNumber: int[], outputFile: string)Calls TryExtract(inputFile, pageNumber, outputFile) on this PdfFileEditor instance.
TryExtract(inputStream: Stream, pageNumber: int[], outputStream: Stream)Calls TryExtract(inputStream, pageNumber, outputStream) on this PdfFileEditor instance.
TryInsert(inputFile: string, insertLocation: int, portFile: string, pageNumber: int[], outputFile: string)Calls TryInsert(inputFile, insertLocation, portFile, pageNumber, outputFile) on this PdfFileEditor instance.
TryInsert(inputStream: Stream, insertLocation: int, portStream: Stream, pageNumber: int[], outputStream: Stream)Calls TryInsert(inputStream, insertLocation, portStream, pageNumber, outputStream) on this PdfFileEditor instance.
TryMakeBooklet(inputFile: string, outputFile: string)Calls TryMakeBooklet(inputFile, outputFile) on this PdfFileEditor instance.
TryMakeBooklet(inputFile: string, outputFile: string, pageSize: PageSize)Calls TryMakeBooklet(inputFile, outputFile, pageSize) on this PdfFileEditor instance.
TryMakeBooklet(inputFile: string, outputFile: string, leftPages: int[], rightPages: int[])Calls TryMakeBooklet(inputFile, outputFile, leftPages, rightPages) on this PdfFileEditor instance.
TryMakeBooklet(inputFile: string, outputFile: string, pageSize: PageSize, leftPages: int[], rightPages: int[])Calls TryMakeBooklet(inputFile, outputFile, pageSize, leftPages, rightPages) on this PdfFileEditor instance.
TrySplitFromFirst(inputFile: string, location: int, outputFile: string)Calls TrySplitFromFirst(inputFile, location, outputFile) on this PdfFileEditor instance.
TrySplitFromFirst(inputStream: Stream, location: int, outputStream: Stream)Calls TrySplitFromFirst(inputStream, location, outputStream) on this PdfFileEditor instance.
TrySplitToEnd(inputFile: string, location: int, outputFile: string)Calls TrySplitToEnd(inputFile, location, outputFile) on this PdfFileEditor instance.
TrySplitToEnd(inputStream: Stream, location: int, outputStream: Stream)Calls TrySplitToEnd(inputStream, location, outputStream) on this PdfFileEditor instance.
TryResizeContents(source: string, destination: string, pages: int[], parameters: ContentsResizeParameters)Calls TryResizeContents(source, destination, pages, parameters) on this PdfFileEditor instance.
TryResizeContents(source: Stream, destination: Stream, pages: int[], parameters: ContentsResizeParameters)Calls TryResizeContents(source, destination, pages, parameters) on this PdfFileEditor instance.
TryResizeContents(source: Stream, destination: Stream, pages: int[], newWidth: double, newHeight: double)Calls TryResizeContents(source, destination, pages, newWidth, newHeight) on this PdfFileEditor instance.
TryMakeBooklet(inputStream: Stream, outputStream: Stream)Calls TryMakeBooklet(inputStream, outputStream) on this PdfFileEditor instance.
TryMakeBooklet(inputStream: Stream, outputStream: Stream, pageSize: PageSize)Calls TryMakeBooklet(inputStream, outputStream, pageSize) on this PdfFileEditor instance.
TryMakeBooklet(inputStream: Stream, outputStream: Stream, leftPages: int[], rightPages: int[])Calls TryMakeBooklet(inputStream, outputStream, leftPages, rightPages) on this PdfFileEditor instance.
TryMakeBooklet(inputStream: Stream, outputStream: Stream, pageSize: PageSize, leftPages: int[], rightPages: int[])Calls TryMakeBooklet(inputStream, outputStream, pageSize, leftPages, rightPages) on this PdfFileEditor instance.
TryMakeNUp(firstInputFile: string, secondInputFile: string, outputFile: string)Calls TryMakeNUp(firstInputFile, secondInputFile, outputFile) on this PdfFileEditor instance.
TryMakeNUp(inputFile: string, outputFile: string, x: int, y: int)Calls TryMakeNUp(inputFile, outputFile, x, y) on this PdfFileEditor instance.
TryMakeNUp(inputFile: string, outputFile: string, x: int, y: int, pageSize: PageSize)Calls TryMakeNUp(inputFile, outputFile, x, y, pageSize) on this PdfFileEditor instance.
TryMakeNUp(inputFiles: string[], outputFile: string, isSidewise: bool)Calls TryMakeNUp(inputFiles, outputFile, isSidewise) on this PdfFileEditor instance.
TryMakeNUp(firstInputStream: Stream, secondInputStream: Stream, outputStream: Stream)Calls TryMakeNUp(firstInputStream, secondInputStream, outputStream) on this PdfFileEditor instance.
TryMakeNUp(inputStream: Stream, outputStream: Stream, x: int, y: int)Calls TryMakeNUp(inputStream, outputStream, x, y) on this PdfFileEditor instance.
TryMakeNUp(inputStream: Stream, outputStream: Stream, x: int, y: int, pageSize: PageSize)Calls TryMakeNUp(inputStream, outputStream, x, y, pageSize) on this PdfFileEditor instance.
TryMakeNUp(inputStreams: Stream[], outputStream: Stream, isSidewise: bool)Calls TryMakeNUp(inputStreams, outputStream, isSidewise) on this PdfFileEditor instance.
ResizeContents(source: string, destination: string, pages: int[], parameters: ContentsResizeParameters)Calls ResizeContents(source, destination, pages, parameters) on this PdfFileEditor instance.
ResizeContents(source: Stream, destination: Stream, pages: int[], parameters: ContentsResizeParameters)Calls ResizeContents(source, destination, pages, parameters) on this PdfFileEditor instance.
ResizeContents(source: string, destination: string, pages: int[], newWidth: double, newHeight: double)Resizes the contents of the given pages of the source file to the new width and height in points, with automatic margins, and saves the result to destination.
ResizeContents(source: Stream, destination: Stream, pages: int[], newWidth: double, newHeight: double)Resizes the contents of the given pages of the source stream to the new width and height in points, with automatic margins, and writes the result to destination.
ResizeContentsPct(source: string, destination: string, pages: int[], newWidth: double, newHeight: double)Calls ResizeContentsPct(source, destination, pages, newWidth, newHeight) on this PdfFileEditor instance.
ResizeContentsPct(source: Stream, destination: Stream, pages: int[], newWidth: double, newHeight: double)Calls ResizeContentsPct(source, destination, pages, newWidth, newHeight) on this PdfFileEditor instance.
AddMargins(source: string, destination: string, pages: int[], leftMargin: double, rightMargin: double, topMargin: double, bottomMargin: double)Calls AddMargins(source, destination, pages, leftMargin, rightMargin, topMargin, bottomMargin) on this PdfFileEditor instance.
AddMargins(source: Stream, destination: Stream, pages: int[], leftMargin: double, rightMargin: double, topMargin: double, bottomMargin: double)Calls AddMargins(source, destination, pages, leftMargin, rightMargin, topMargin, bottomMargin) on this PdfFileEditor instance.
AddMarginsPct(source: string, destination: string, pages: int[], leftMargin: double, rightMargin: double, topMargin: double, bottomMargin: double)Calls AddMarginsPct(source, destination, pages, leftMargin, rightMargin, topMargin, bottomMargin) on this PdfFileEditor instance.
AddMarginsPct(source: Stream, destination: Stream, pages: int[], leftMargin: double, rightMargin: double, topMargin: double, bottomMargin: double)Calls AddMarginsPct(source, destination, pages, leftMargin, rightMargin, topMargin, bottomMargin) on this PdfFileEditor instance.
MakeBooklet(inputStream: Stream, outputStream: Stream)Writes a booklet of the input PDF to the output stream: each output page holds two source pages side by side, ordered so that the sheets printed double-sided and folded form a booklet.
MakeBooklet(inputStream: Stream, outputStream: Stream, pageSize: PageSize)Writes a booklet of the input PDF to the output stream using the given sheet size, ordered so that the sheets printed double-sided and folded form a booklet.
MakeBooklet(inputStream: Stream, outputStream: Stream, leftPages: int[], rightPages: int[])Writes a booklet to the output stream where output page i shows source page leftPages[i] on the left and rightPages[i] on the right; an out-of-range page number leaves that half blank.
MakeBooklet(inputStream: Stream, outputStream: Stream, pageSize: PageSize, leftPages: int[], rightPages: int[])Writes a booklet with the given sheet size to the output stream where output page i shows source page leftPages[i] on the left and rightPages[i] on the right.
MakeNUp(inputFile: string, outputFile: string, x: int, y: int)Places the pages of the input file onto sheets of x columns by y rows and saves the result to outputFile.
MakeNUp(inputFile: string, outputFile: string, x: int, y: int, pageSize: PageSize)Places the pages of the input file onto sheets of the given size, x columns by y rows, and saves the result to outputFile.
MakeNUp(inputStream: Stream, outputStream: Stream, x: int, y: int)Places the pages of the input PDF onto sheets of x columns by y rows and writes the result to the output stream.
MakeNUp(inputStream: Stream, outputStream: Stream, x: int, y: int, pageSize: PageSize)Places the pages of the input PDF onto sheets of the given size, x columns by y rows, and writes the result to the output stream.
MakeNUp(firstInputFile: string, secondInputFile: string, outputFile: string)Pairs page i of the first file with page i of the second file side by side on one output page and saves the result to outputFile.
MakeNUp(firstInputStream: Stream, secondInputStream: Stream, outputStream: Stream)Pairs page i of the first PDF with page i of the second PDF side by side on one output page and writes the result to the output stream.
MakeNUp(inputFiles: string[], outputFile: string, isSidewise: bool)Combines page i of every input file onto one output page, side by side when isSidewise is true or stacked vertically otherwise, and saves the result to outputFile.
MakeNUp(inputStreams: Stream[], outputStream: Stream, isSidewise: bool)Combines page i of every input PDF onto one output page, side by side when isSidewise is true or stacked vertically otherwise, and writes the result to the output stream.
SplitToBulks(inputFile: string, numberOfPage: int[][])Splits the PDF file into several documents, one per page range; each range is [start, end] (1-based, inclusive).
SplitToBulks(inputStream: Stream, numberOfPage: int[][])Splits the PDF in the stream into several documents, one per page range; each range is [start, end] (1-based, inclusive).
SplitToPages(inputStream: Stream)Splits the PDF in the stream into single-page documents and returns one read-only stream per page.
SplitToPages(inputFile: string, fileNameTemplate: string)Splits the PDF file into single-page documents saved to files named from the template: %NUM% or {0} is replaced by the 1-based page number, otherwise _N is added before the extension.
SplitToPages(inputStream: Stream, fileNameTemplate: string)Splits the PDF in the stream into single-page documents saved to files named from the template: %NUM% or {0} is replaced by the 1-based page number, otherwise _N is added before the extension.
Append(inputPdf: byte[], portPdf: byte[], startPage: int, endPage: int)Append pages from a source PDF to an input PDF.
Append(inputPdf: byte[], portPdfs: byte[][], startPage: int, endPage: int)Append pages from multiple source PDFs to an input PDF.
Insert(inputPdf: byte[], insertLocation: int, portPdf: byte[], startPage: int, endPage: int)Insert pages from a source PDF into a destination PDF at a given position.
Insert(inputPdf: byte[], insertLocation: int, portPdf: byte[], pageNumbers: int[])Insert specific pages from a source PDF into a destination PDF at a given position.
Append(inputStream: Stream, portStreams: Stream[], startPage: int, endPage: int, outputStream: Stream)Append pages from source stream(s) to input stream and write to output.
Append(inputStream: Stream, portStream: Stream, startPage: int, endPage: int, outputStream: Stream)Append pages from a single source stream to input stream and write to output.
Insert(inputStream: Stream, insertLocation: int, portStream: Stream, startPage: int, endPage: int, outputStream: Stream)Insert pages from source stream into input stream at given position.
Insert(inputStream: Stream, insertLocation: int, portStream: Stream, pageNumber: int[], outputStream: Stream)Insert specific pages from source stream into input stream.
Insert(inputFile: string, insertLocation: int, portFile: string, startPage: int, endPage: int, outputFile: string)Insert pages from a source PDF into a destination PDF at a given position and write to output file.
Insert(inputFile: string, insertLocation: int, portFile: string, pageNumber: int[], outputFile: string)Insert specific pages from a source PDF into a destination PDF at a given position and write to output file.
Append(inputFile: string, portFiles: string[], startPage: int, endPage: int, outputFile: string)Append pages from multiple source PDF files to an input PDF and write to output file.
Append(inputFile: string, portFile: string, startPage: int, endPage: int, outputFile: string)Append pages from a single source PDF file to an input PDF and write to output file.
MakeBooklet(inputPdf: byte[])Create a booklet from a PDF: every output page is one SHEET SIDE carrying two source pages side by side, so that printed double-sided and folded the sheets form a booklet.
MakeBooklet(inputPdf: byte[], pageSize: PageSize)Create a booklet from a PDF using a specified page size.
MakeBooklet(inputPdf: byte[], leftPages: int[], rightPages: int[])Create a booklet from explicit left/right page lists: output page i carries leftPages[i] on its left half and rightPages[i] on its right; an index outside the source page range (0, negative, or past the end) leaves that half blank.
MakeBooklet(inputPdf: byte[], pageSize: PageSize, leftPages: int[], rightPages: int[])Create a booklet using specified left/right pages and a custom page size.
MakeBooklet(inputFile: string, outputFile: string)MakeBooklet from file path to file path.
MakeBooklet(inputFile: string, outputFile: string, pageSize: PageSize)MakeBooklet from file path to file path with a specific page size.
MakeBooklet(inputFile: string, outputFile: string, leftPages: int[], rightPages: int[])MakeBooklet from file path to file path with left/right page arrays.
MakeBooklet(inputFile: string, outputFile: string, pageSize: PageSize, leftPages: int[], rightPages: int[])MakeBooklet from file path to file path with page size and left/right page arrays.
Concatenate(inputFiles)Concatenate multiple PDF documents into one.
Concatenate(inputFiles: string[], outputFile: string)Concatenate multiple PDF files into one output file.
Concatenate(firstInputFile: string, secInputFile: string, outputFile: string)Concatenate two PDF files into one output file.
Concatenate(firstInputFile: string, secInputFile: string, blankPageFile: string, outputFile: string)Concatenate two PDF files with a blank-page separator inserted between them.
Concatenate(inputStream: Stream[], outputStream: Stream)Concatenate multiple PDF streams into one output stream.
Concatenate(firstInputStream: Stream, secInputStream: Stream, outputStream: Stream)Concatenate two PDF streams into one output stream.
Concatenate(firstInputStream: Stream, secInputStream: Stream, blankPageStream: Stream, outputStream: Stream)Concatenate two PDF streams with a blank-page separator inserted between them.
Concatenate(src: Document[], dest: Document)Concatenate the pages of src into the existing dest document.
AddPageBreak(src: Document, dest: Document, pageBreaks: PageBreak[])Items the Concatenate path skipped over because their input failed to parse. Empty when no corruption was tolerated (the default aborts on
AddPageBreak(src: Stream, dest: Stream, pageBreaks: PageBreak[])Stream overload of AddPageBreak(Document, Document, PageBreak[]).
AddPageBreak(src: string, dest: string, pageBreaks: PageBreak[])File-path overload of AddPageBreak(Document, Document, PageBreak[]).
PdfFileEditor()Creates a file editor with default settings.
ResizeContents(source: Document, parameters: ContentsResizeParameters)Resize the contents of all pages in a document by applying a scale/translate transform derived from the margin parameters.
ResizeContents(source: Document, pages: int[], parameters: ContentsResizeParameters)Resize the contents of specific pages in a document by applying a scale/translate transform derived from the margin parameters.
Extract(inputPdf: byte[], startPage: int, endPage: int)Extract pages from a PDF document.
Split(inputPdf: byte[])Split a PDF into individual page files.
Delete(inputPdf: byte[], pageNumbers)Delete pages from a PDF.
Extract(inputPdf: byte[], pageNumbers: int[])Extract specific pages (by page number array) from a PDF.
SplitFromFirst(inputPdf: byte[], pageCount: int)Extract the first N pages from a PDF.
SplitToEnd(inputPdf: byte[], startPage: int)Extract pages from startPage to the end of the document.
SplitToPages(inputPdf: byte[])Split a PDF into individual single-page documents (alias for Split).
SplitToPages(inputFile: string)Split a PDF file at the given path into MemoryStreams, one per page .
SplitToBulks(inputPdf: byte[], pageRanges: int[][]?)Split a PDF into multiple parts based on page ranges.
SplitFromFirst(inputFile: string, location: int, outputFile: string)Split from first N pages and write to output file.
SplitToEnd(inputFile: string, location: int, outputFile: string)Split from startPage to end and write to output file.
Extract(inputFile: string, pageNumber: int[], outputFile: string)Extract specific pages from a PDF file and write to output file.
Extract(inputFile: string, startPage: int, endPage: int, outputFile: string)Extract a range of pages from a PDF file and write to output file.
Extract(inputStream: Stream, startPage: int, endPage: int, outputStream: Stream)Extract a range of pages from a stream and write to an output stream .
Extract(inputStream: Stream, pageNumber: int[], outputStream: Stream)Extract specific pages from a stream and write to output stream.
Delete(inputStream: Stream, pageNumber: int[], outputStream: Stream)Delete specific pages from a stream and write to output stream.
SplitFromFirst(inputStream: Stream, location: int, outputStream: Stream)Split a stream from the first page up to pageCount.
SplitToEnd(inputStream: Stream, location: int, outputStream: Stream)Split a stream from startPage to the end.
Delete(inputFile: string, pageNumber: int[], outputFile: string)Delete specific pages from a PDF file and write to output file.

See Also

 English