Scripting - How to prevent OCR on specific pages of a document
Issue
How to prevent OCR on specific pages of a document?
Solution
Often, OCR need not be performed for all pages. This is the case when data has been found on a first page, or a page is marked as an attachment by patchcode or other means.
The locators allow for restricting the search region (and hence the automatically performed OCR) only for the first, middle and last pages, respectively. To inhibit OCR on an arbitrary page, you need to write a short piece of script in the BeforeProcessXDoc event, which is the first event being fired before anything else is done with the Document.
Insert the script code shown below. This script will prevent the server from performing OCR on all pages except the first one. Without OCR, locators will not extract anything on these pages.
Private Sub Document_BeforeProcessXDoc(pXDoc As CASCADELib.CscXDocument) Dim i As Long For i = 1 To pXDoc.CDoc.Pages.Count - 1 pXDoc.CDoc.Pages(i).SuppressOCR = True Next i End Sub
Keep in mind that if a locator runs on project level then a page license is still required for each page as KTM Server is working on each page.
Level of Complexity
Moderate
Applies to
Product | Version | Build | Environment | Hardware |
---|---|---|---|---|
Kofax Transformation Module | All |
References
Add any references to other internal or external articles
Article # 3035678