Method Reorder
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
sourcebyte[]The source PDF's bytes.
orderIReadOnlyList<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.
outputStreamA writable stream for the result.
optionsPdfAssemblyOptionsThe 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,orderoroutputis null.- ArgumentException
orderis 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
sourcePathstringThe source PDF's path.
orderIReadOnlyList<int>A permutation of 1..N, where N is the source's page count.
outputPathstringThe path to write.
optionsPdfAssemblyOptionsThe assembly settings, or null for the defaults.
Returns
- PdfAssemblyResult
What was produced, and everything that could not be carried.
Exceptions
- ArgumentNullException
A path or
orderis null.- ArgumentException
orderis not a permutation of 1..N.