Table of Contents

Interface IPdfPageOrganizerService

Namespace
PdfEngine.Pages
Assembly
PdfEngine.Abstractions.dll

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

document IPdfDocument
arrangement IReadOnlyList<PageArrangementEntry>
targetPath string
cancellationToken CancellationToken

Returns

ValueTask

DeletePageAsync(IPdfDocument, int, CancellationToken)

Deletes a page from the open document.

ValueTask DeletePageAsync(IPdfDocument document, int pageNumber, CancellationToken cancellationToken = default)

Parameters

document IPdfDocument

An open document of this engine.

pageNumber int

The page number, starting at 1.

cancellationToken CancellationToken

Cancels the operation.

Returns

ValueTask

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

document IPdfDocument

An open document of this engine.

pageNumbers IReadOnlyList<int>

The pages to copy, starting at 1, in the order of the new document.

targetPath string

The file to write.

cancellationToken CancellationToken

Cancels the operation.

Returns

ValueTask

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

document IPdfDocument

An open document of this engine.

targetIndex int

The position of the new page, starting at 0 (0 inserts it before the first page).

widthPoints double

The page width in points (default 612, US Letter).

heightPoints double

The page height in points (default 792, US Letter).

cancellationToken CancellationToken

Cancels the operation.

Returns

ValueTask

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

sourceFiles IReadOnlyList<string>

The PDF files to merge.

targetPath string

The file to write.

progress IProgress<double>

Receives the fraction done, from 0 to 1.

cancellationToken CancellationToken

Cancels the operation.

Returns

ValueTask

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

document IPdfDocument

An open document of this engine.

pageNumber int

The page number, starting at 1.

newRotation PageRotation

The new rotation of the page. It replaces the current rotation.

cancellationToken CancellationToken

Cancels the operation.

Returns

ValueTask

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

document IPdfDocument

An open document of this engine.

pageNumbersPerSplit IReadOnlyList<int>

The number of pages of each part, in order.

outputDirectory string

The folder for the new files.

filePrefix string

The start of each file name.

cancellationToken CancellationToken

Cancels the operation.

Returns

ValueTask