PdfFileEditor.TryExtract

TryExtract(string, int, int, string)

Extracts pages from input file,saves as a new Pdf file.

public bool TryExtract(string inputFile, int startPage, int endPage, string outputFile)
ParameterTypeDescription
inputFileStringInput Pdf file path.
startPageInt32Start page number.
endPageInt32End page number.
outputFileStringOutput Pdf file path.

Return Value

True for success, or false.

Remarks

The TryExtract method is like the Extract method, except the TryExtract method does not throw an exception if the operation fails.

Examples

PdfFileEditor pfe = new PdfFileEditor();
bool result = pfe.TryExtract("input.pdf", 3, 7, "output.pdf");

See Also


TryExtract(string, int[], string)

Extracts pages specified by number array, saves as a new PDF file.

public bool TryExtract(string inputFile, int[] pageNumber, string outputFile)
ParameterTypeDescription
inputFileStringInput file path.
pageNumberInt32[]Index of page out of the input file.
outputFileStringOutput file path.

Return Value

true if operation completed successfully; otherwise, false.

Remarks

The TryExtract method is like the Extract method, except the TryExtract method does not throw an exception if the operation fails.

Examples

PdfFileEditor pfe = new PdfFileEditor();
bool result = pfe.TryExtract("input.pdf", new int[] { 3, 5, 7 }, "output.pdf");

See Also


TryExtract(Stream, int[], Stream)

Extracts pages specified by number array, saves as a new Pdf file.

public bool TryExtract(Stream inputStream, int[] pageNumber, Stream outputStream)
ParameterTypeDescription
inputStreamStreamInput file Stream.
pageNumberInt32[]Index of page out of the input file.
outputStreamStreamOutput file stream.

Return Value

True for success, or false.

Remarks

The TryExtract method is like the Extract method, except the TryExtract method does not throw an exception if the operation fails.

Examples

PdfFileEditor pfe = new PdfFileEditor();
Stream sourceStream = new FileStream("file1.pdf", FileMode.Open, FileAccess.Read);
Stream outStream = new FileStream("out.pdf", FileMode.Create, FileAccess.Write);
bool result = pfe.TryExtract(sourceStream, new int[] { 3, 5, 8 }, outStream);

See Also