Method AddTextLayer
- Namespace
- SoftZenPdf.Ocr
- Assembly
- SoftZenPdf.Ocr.dll
AddTextLayer(string, string, string?)
Makes an existing scanned PDF searchable: recognises the largest image on each page and adds the text over it as an incremental update, so the original file, its scans (never re-encoded), bookmarks and metadata are kept byte for byte, and a PDF/A source stays PDF/A.
public OcrPdfUpdateResult AddTextLayer(string inputPath, string outputPath, string? password = null)
Parameters
inputPathstringThe scanned PDF.
outputPathstringThe searchable PDF to write; it may not be
inputPath.passwordstringFor encrypted files, the user or owner password.
Returns
- OcrPdfUpdateResult
The text of each page, with null for pages left unchanged, and why they were.
Remarks
Images encoded with JBIG2 or JPEG 2000, and inline images, cannot be decoded; their pages are left unchanged and reported in Warnings. PageOptions and Conformance do not apply.
Exceptions
- NotSupportedException
Conformance is set, or the file needed repair to open.
- UnauthorizedAccessException
The file's permissions do not allow changing page content.
- PdfPasswordException
The file is encrypted and the password is missing or wrong.
AddTextLayer(byte[], Stream, string?)
Makes an existing scanned PDF held in memory searchable; see AddTextLayer(string, string, string?).
public OcrPdfUpdateResult AddTextLayer(byte[] pdf, Stream output, string? password = null)
Parameters
pdfbyte[]The scanned PDF's bytes.
outputStreamThe stream to write the searchable PDF to; it is left open.
passwordstringFor encrypted files, the user or owner password.