Table of Contents

Method Reorder

Namespace
DocWright.Formats.Pdf
Assembly
DocWright.Formats.Pdf.dll

Reorder(byte[], IReadOnlyList<int>, Stream, PdfAssemblyOptions?)

Writes a document whose pages are the source's in a new order.

public static PdfAssemblyResult Reorder(byte[] source, IReadOnlyList<int> order, Stream output, PdfAssemblyOptions? options = null)

Parameters

source byte[]

The source PDF's bytes.

order IReadOnlyList<int>

A permutation of 1..N, where N is the source's page count: every page exactly once, in the order the output should have them.

output Stream

A writable stream for the result.

options PdfAssemblyOptions

The assembly settings, or null for the defaults.

Returns

PdfAssemblyResult

What was produced, and everything that could not be carried.

Remarks

A partial list is refused rather than interpreted. "Reorder pages 3 and 1" has two plausible readings — keep only those two, or move them and leave the rest somewhere — and guessing between them silently deletes a document's pages. Keeping a subset is Extract(byte[], PageRange, Stream, PdfAssemblyOptions?); an arbitrary sequence, repeats included, is AppendPage(int, int).

Exceptions

ArgumentNullException

source, order or output is null.

ArgumentException

order is not a permutation of 1..N.

Reorder(string, IReadOnlyList<int>, string, PdfAssemblyOptions?)

Writes a document whose pages are the source's in a new order.

public static PdfAssemblyResult Reorder(string sourcePath, IReadOnlyList<int> order, string outputPath, PdfAssemblyOptions? options = null)

Parameters

sourcePath string

The source PDF's path.

order IReadOnlyList<int>

A permutation of 1..N, where N is the source's page count.

outputPath string

The path to write.

options PdfAssemblyOptions

The assembly settings, or null for the defaults.

Returns

PdfAssemblyResult

What was produced, and everything that could not be carried.

Exceptions

ArgumentNullException

A path or order is null.

ArgumentException

order is not a permutation of 1..N.