Interface IPdfPageOrganizerService
Rotates, deletes, inserts, extracts, merges, splits and arranges pages.
public interface IPdfPageOrganizerService
Methods
ArrangePagesAsync(IPdfDocument, IReadOnlyList<PageArrangementEntry>, string, CancellationToken)
Writes a new document whose pages are exactly arrangement, in order.
Reordering, deleting and rotating pages are all the same operation expressed this way: a page moves by changing position in the list, is deleted by not appearing, and is rotated by its entry saying so. Doing it in one pass means the result is always a consistent document rather than the outcome of a sequence of edits that could half-fail.
ValueTask ArrangePagesAsync(IPdfDocument document, IReadOnlyList<PageArrangementEntry> arrangement, string targetPath, CancellationToken cancellationToken = default)
Parameters
documentIPdfDocumentarrangementIReadOnlyList<PageArrangementEntry>targetPathstringcancellationTokenCancellationToken
Returns
DeletePageAsync(IPdfDocument, int, CancellationToken)
Deletes a page from the open document.
ValueTask DeletePageAsync(IPdfDocument document, int pageNumber, CancellationToken cancellationToken = default)
Parameters
documentIPdfDocumentAn open document of this engine.
pageNumberintThe page number, starting at 1.
cancellationTokenCancellationTokenCancels the operation.
Returns
ExtractPagesAsync(IPdfDocument, IReadOnlyList<int>, string, CancellationToken)
Writes a new document that contains the given pages.
ValueTask ExtractPagesAsync(IPdfDocument document, IReadOnlyList<int> pageNumbers, string targetPath, CancellationToken cancellationToken = default)
Parameters
documentIPdfDocumentAn open document of this engine.
pageNumbersIReadOnlyList<int>The pages to copy, starting at 1, in the order of the new document.
targetPathstringThe file to write.
cancellationTokenCancellationTokenCancels the operation.
Returns
InsertBlankPageAsync(IPdfDocument, int, double, double, CancellationToken)
Inserts an empty page into the open document.
ValueTask InsertBlankPageAsync(IPdfDocument document, int targetIndex, double widthPoints = 612, double heightPoints = 792, CancellationToken cancellationToken = default)
Parameters
documentIPdfDocumentAn open document of this engine.
targetIndexintThe position of the new page, starting at 0 (0 inserts it before the first page).
widthPointsdoubleThe page width in points (default 612, US Letter).
heightPointsdoubleThe page height in points (default 792, US Letter).
cancellationTokenCancellationTokenCancels the operation.
Returns
MergeDocumentsAsync(IReadOnlyList<string>, string, IProgress<double>?, CancellationToken)
Writes a new document that contains all pages of the source files, in order.
ValueTask MergeDocumentsAsync(IReadOnlyList<string> sourceFiles, string targetPath, IProgress<double>? progress = null, CancellationToken cancellationToken = default)
Parameters
sourceFilesIReadOnlyList<string>The PDF files to merge.
targetPathstringThe file to write.
progressIProgress<double>Receives the fraction done, from 0 to 1.
cancellationTokenCancellationTokenCancels the operation.
Returns
RotatePageAsync(IPdfDocument, int, PageRotation, CancellationToken)
Sets the rotation of a page in the open document.
ValueTask RotatePageAsync(IPdfDocument document, int pageNumber, PageRotation newRotation, CancellationToken cancellationToken = default)
Parameters
documentIPdfDocumentAn open document of this engine.
pageNumberintThe page number, starting at 1.
newRotationPageRotationThe new rotation of the page. It replaces the current rotation.
cancellationTokenCancellationTokenCancels the operation.
Returns
SplitDocumentAsync(IPdfDocument, IReadOnlyList<int>, string, string, CancellationToken)
Splits the document into several files.
ValueTask SplitDocumentAsync(IPdfDocument document, IReadOnlyList<int> pageNumbersPerSplit, string outputDirectory, string filePrefix, CancellationToken cancellationToken = default)
Parameters
documentIPdfDocumentAn open document of this engine.
pageNumbersPerSplitIReadOnlyList<int>The number of pages of each part, in order.
outputDirectorystringThe folder for the new files.
filePrefixstringThe start of each file name.
cancellationTokenCancellationTokenCancels the operation.