Click or drag to resize
Pdftools logo

ProcessorProcess Method

Apply OCR to a PDF document

Process the input PDF document with OCR according to the specified options. The processed document is written to the output stream.

Non-critical processing issues raise a Warning. It is recommended to review the WarningCategory and handle them if necessary for the application.


Namespace: PdfTools.Ocr
Assembly: PdfTools (in PdfTools.dll) Version: 1.16.0+362ed17524d0f96db0bdf45362ca9dfd8e1a4428
Syntax
C#
public Document Process(
	Document document,
	Engine engine,
	Stream outStream,
	OcrOptions options = null,
	OutputOptions outOptions = null
)

Parameters

document  Document
The input PDF document to process
engine  Engine
The OCR engine to use for recognition. This parameter may be for operations that do not require OCR, such as RemoveText. For all other modes, a valid engine must be provided.
outStream  Stream
The stream to which the output PDF is written. The stream must support both random read and write access.
options  OcrOptions  (Optional)
The OCR processing options. If , default options are used.
outOptions  OutputOptions  (Optional)
The PDF output options, e.g. to encrypt the output document.

Return Value

Document

The resulting output PDF which can be used as a new input for further processing.

Note that this object must be disposed before the output stream object (method argument outStream).

Exceptions
ExceptionCondition
LicenseExceptionThe license check has failed.
IOExceptionWriting to the outStream failed.
ProcessingExceptionThe document could not be processed.
ArgumentExceptionAn OCR engine is required for the specified options but engine is .
ArgumentExceptionThe options specifies invalid or contradictory settings.
ArgumentExceptionThe outOptions specifies document encryption for a PDF/A file, which is not allowed.
GenericExceptionAn unexpected failure occurred.
CorruptExceptionAn input image in the document is corrupt and cannot be read.
PasswordExceptionThe document is encrypted and the password is invalid.
ConformanceExceptionThe document has an invalid conformance level.
UnsupportedFeatureExceptionThe input PDF contains unrendered XFA form fields. See Xfa for more information.
ArgumentNullExceptionif document is .
ArgumentNullExceptionif outStream is .
See Also