This guide walks you through installing and configuring Apryse’s Data Extraction Module so you can start extracting data from PDFs quickly and reliably.
Using PIP with Python
When using Python on Windows or Linux you can install the package via PIP with this command:
If you are using PIP or NPM, you may skip setting AddResourceSearchPath. Otherwise, follow the directions below.
The first thing to set up before the module can be used is the location of the Lib directory under which the external add-ons are installed, so that the SDK knows where to look for them. This is achieved via the PDFNet AddResourceSearchPath function. If a relative path is used, it is based on the end-user executable.
Note: do not specify the actual Windows, Linux, MacOS directory, where the individual executables are, but its parent folder.
For error handling purposes, it is generally advisable to test whether the module is available via the IsModuleAvailable function. Since the Data Extraction suite consists of multiple modules, an extra parameter is used to clarify the component to test.
8 // Unable to run Data Extraction: PDFTron SDK AIFormFieldExtractor module not available.
9}
1if not DataExtractionModule.IsModuleAvailable(DataExtractionModule.e_Tabular):
2 pass # Unable to run Data Extraction: PDFTron SDK Tabular Data module not available.
3if not DataExtractionModule.IsModuleAvailable(DataExtractionModule.e_DocStructure):
4 pass # Unable to run Data Extraction: PDFTron SDK Structured Output module not available.
5if not DataExtractionModule.IsModuleAvailable(DataExtractionModule.e_Form):
6 pass # Unable to run Data Extraction: PDFTron SDK AIFormFieldExtractor module not available.
1if !DataExtractionModule.IsModuleAvailable(DataExtractionModule::E_Tabular) then
2 # Unable to run Data Extraction: PDFTron SDK Tabular Data module not available.
3end
4if !DataExtractionModule.IsModuleAvailable(DataExtractionModule::E_DocStructure) then
5 # Unable to run Data Extraction: PDFTron SDK Structured Output module not available.
6end
7if !DataExtractionModule.IsModuleAvailable(DataExtractionModule::E_Form) then
8 # Unable to run Data Extraction: PDFTron SDK AIFormFieldExtractor module not available.
9end
1If Not DataExtractionModule.IsModuleAvailable(DataExtractionModule.DataExtractionEngine.e_tabular) Then
2 ' Unable to run Data Extraction: PDFTron SDK Tabular Data module not available.
3End If
4If Not DataExtractionModule.IsModuleAvailable(DataExtractionModule.DataExtractionEngine.e_doc_structure) Then
5 ' Unable to run Data Extraction: PDFTron SDK Structured Output module not available.
6End If
7If Not DataExtractionModule.IsModuleAvailable(DataExtractionModule.DataExtractionEngine.e_form) Then
8 ' Unable to run Data Extraction: PDFTron SDK AIFormFieldExtractor module not available.
9End If
If you have the module installed but the function still returns false, please double check that the correct path was used in AddResourceSearchPath earlier.
Data Extraction Options
Although the default options will satisfy most common use cases, we offer a couple of options to customize the extraction behavior and unlock lesser-used functionality.
The options object is passed as the last parameter to any extraction function, as shown below.
Select OCR Language
Use the Language option to set the preferred OCR language(s). If you work with scanned documents in languages other than English, specify one or more 3-letter ISO 639-2 language codes, separated by spaces. For example, "eng deu spa fra" for English, German, Spanish, French. You may also use comma or plus as a separator.
Supported languages:
eng: English
deu or ger: German
fra or fre: French
ita: Italian
rus: Russian
spa: Spanish
Note: Listing too many languages at once may hurt performance and accuracy. If you know the exact language, it is always best to use that single setting.
1DataExtractionOptions options = new DataExtractionOptions();
2options.SetLanguage("fra spa"); // French and Spanish
Use the PDFPassword option to specify a PDF password if one is required.
Encrypted PDF files that are protected by a password may only be opened when the password is specified in addition to the filename. No password is necessary for files that can be viewed without any authentication.
1DataExtractionOptions options = new DataExtractionOptions();
2options.SetPDFPassword("password123"); // password for input PDF
Use the Pages option to restrict the extraction to a selected range of pages.
This can be a single page number (such as "1" for the first page), or a range separated by a dash (such as "1-5", or "7-" for 7 and beyond). An empty string means all pages are extracted.
1DataExtractionOptions options = new DataExtractionOptions();
You can specify regions to include or exclude from analysis for each page in a document using the Inclusion Zone and Exclusion Zone options for a page. These options specify rectangles in user-space coordinates that allow developers to either include or exclude a region from analysis. For example, if a document has a table that you don't want to analyze, you could specify it's bounding box as an exclusion zone, or if a document has only one paragraph that you care about, you could use an inclusion zone. If no zones are specified for a page, the entire page is included in analysis.
Inclusion and exclusion zones can be combined to create complex regions of interest. Inclusions zones are combined by union, and exclusion zones are subtracted.
This option is only supported for the Form, FormKeyValue, and GenericKeyValue engines at this time.
Inclusion and Exclusion example
1DataExtractionOptions options = new DataExtractionOptions();
2
3RectCollection p4InclusionZones = new RectCollection();
4RectCollection p4ExclusionZones = new RectCollection();
Specifies if Deep Learning is used with table recognition in the DocStructure engine. Table recognition accuracy improves at the cost of increased processing time. This only affects the DocStructure engine.
1DataExtractionOptions options = new DataExtractionOptions();
2options.SetDeepLearningAssist(true); // Enable Deep learning assistant
When automatically detecting form fields and adding them to a document, you can force the module to preserve any existing form annotations that are already present in the document, only adding newly detected fields.
1PDFDoc doc = new PDFDoc("formfields.pdf");
2DataExtractionOptions options = new DataExtractionOptions();