@pdftron/pdfnet-node-samples 9.5.0-2 → 9.5.0-3-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/{samples/AddImageTest → AddImageTest}/AddImageTest.js +2 -2
  2. package/{samples/AdvancedImagingTest → AdvancedImagingTest}/AdvancedImagingTest.js +6 -6
  3. package/{samples/AnnotationTest → AnnotationTest}/AnnotationTest.js +2 -2
  4. package/BarcodeTest/BarcodeTest.js +120 -0
  5. package/{samples/BookmarkTest → BookmarkTest}/BookmarkTest.js +2 -2
  6. package/{samples/CAD2PDFTest → CAD2PDFTest}/CAD2PDFTest.js +6 -6
  7. package/{samples/ContentReplacerTest → ContentReplacerTest}/ContentReplacerTest.js +2 -2
  8. package/ConvertPrintTest/ConvertPrintTest.js +153 -0
  9. package/{samples/ConvertTest → ConvertTest}/ConvertTest.js +13 -80
  10. package/DataExtractionTest/DataExtractionTest.js +311 -0
  11. package/{samples/DigitalSignaturesTest → DigitalSignaturesTest}/DigitalSignaturesTest.js +127 -13
  12. package/DocumentCreationTest/DocumentCreationTest.js +409 -0
  13. package/{samples/ElementBuilderTest → ElementBuilderTest}/ElementBuilderTest.js +2 -2
  14. package/{samples/ElementEditTest → ElementEditTest}/ElementEditTest.js +2 -2
  15. package/{samples/ElementReaderAdvTest → ElementReaderAdvTest}/ElementReaderAdvTest.js +2 -2
  16. package/{samples/ElementReaderTest → ElementReaderTest}/ElementReaderTest.js +2 -2
  17. package/{samples/EncTest → EncTest}/EncTest.js +2 -2
  18. package/{samples/FDFTest → FDFTest}/FDFTest.js +2 -2
  19. package/FindReplaceTest/FindReplaceTest.js +56 -0
  20. package/{samples/HTML2PDFTest → HTML2PDFTest}/HTML2PDFTest.js +35 -36
  21. package/{samples/HighlightsTest → HighlightsTest}/HighlightsTest.js +2 -2
  22. package/{samples/ImageExtractTest → ImageExtractTest}/ImageExtractTest.js +4 -4
  23. package/{samples/ImpositionTest → ImpositionTest}/ImpositionTest.js +2 -2
  24. package/{samples/InteractiveFormsTest → InteractiveFormsTest}/InteractiveFormsTest.js +2 -2
  25. package/{samples/JBIG2Test → JBIG2Test}/JBIG2Test.js +8 -8
  26. package/{samples/LicenseKey → LicenseKey}/LicenseKey.js +2 -2
  27. package/{samples/LogicalStructureTest → LogicalStructureTest}/LogicalStructureTest.js +2 -2
  28. package/{samples/OCRTest → OCRTest}/OCRTest.js +7 -6
  29. package/{samples/OfficeTemplateTest → OfficeTemplateTest}/OfficeTemplateTest.js +3 -3
  30. package/{samples/OfficeToPDFTest → OfficeToPDFTest}/OfficeToPDFTest.js +2 -2
  31. package/{samples/OptimizerTest → OptimizerTest}/OptimizerTest.js +2 -2
  32. package/{samples/PDF2HtmlTest → PDF2HtmlTest}/PDF2HtmlTest.js +7 -7
  33. package/{samples/PDF2OfficeTest → PDF2OfficeTest}/PDF2OfficeTest.js +7 -7
  34. package/{samples/PDFATest → PDFATest}/PDFATest.js +2 -2
  35. package/{samples/PDFDocMemoryTest → PDFDocMemoryTest}/PDFDocMemoryTest.js +2 -2
  36. package/{samples/PDFDrawTest → PDFDrawTest}/PDFDrawTest.js +2 -2
  37. package/{samples/PDFLayersTest → PDFLayersTest}/PDFLayersTest.js +2 -2
  38. package/{samples/PDFPackageTest → PDFPackageTest}/PDFPackageTest.js +2 -2
  39. package/{samples/PDFPageTest → PDFPageTest}/PDFPageTest.js +2 -2
  40. package/{samples/PDFRedactTest → PDFRedactTest}/PDFRedactTest.js +2 -2
  41. package/PDFUATest/PDFUATest.js +88 -0
  42. package/{samples/PageLabelsTest → PageLabelsTest}/PageLabelsTest.js +2 -2
  43. package/{samples/PatternTest → PatternTest}/PatternTest.js +2 -2
  44. package/{samples/RectTest → RectTest}/RectTest.js +2 -2
  45. package/{samples/SDFTest → SDFTest}/SDFTest.js +4 -5
  46. package/{samples/StamperTest → StamperTest}/StamperTest.js +2 -2
  47. package/TestFiles/BusinessCardTemplate.pdf +0 -0
  48. package/TestFiles/Email.pdf +0 -0
  49. package/TestFiles/Fishermen.docx +0 -0
  50. package/TestFiles/Font_licenses.txt +140 -0
  51. package/TestFiles/Invoice.pdf +0 -0
  52. package/TestFiles/License.txt +1 -0
  53. package/TestFiles/Misc-Fixed.pfa +1166 -0
  54. package/TestFiles/NotoSans_with_hindi.ttf +0 -0
  55. package/TestFiles/Output/empty +1 -0
  56. package/TestFiles/SHA-2 Root USERTrust RSA CA Sectigo timestamping.crt +34 -0
  57. package/TestFiles/SYH_Letter.docx +0 -0
  58. package/TestFiles/Scientific_Publication.pdf +0 -0
  59. package/TestFiles/TigerText.pdf +0 -0
  60. package/TestFiles/US061222892-a.pdf +0 -0
  61. package/TestFiles/apryse.bmp +0 -0
  62. package/TestFiles/apryse.cer +0 -0
  63. package/TestFiles/apryse.pfx +0 -0
  64. package/TestFiles/autotag_input.pdf +0 -0
  65. package/TestFiles/butterfly.png +0 -0
  66. package/TestFiles/credit card numbers.pdf +0 -0
  67. package/TestFiles/dice.jpg +0 -0
  68. package/TestFiles/dice.u3d +0 -0
  69. package/TestFiles/doc_to_sign.pdf +0 -0
  70. package/TestFiles/factsheet_Arabic.docx +0 -0
  71. package/TestFiles/financial.pdf +0 -0
  72. package/TestFiles/find-replace-test.pdf +0 -0
  73. package/TestFiles/find-replace-test_(en_to_fr).xlf +88 -0
  74. package/TestFiles/fish.pdf +0 -0
  75. package/TestFiles/font.ttf +0 -0
  76. package/TestFiles/form1.pdf +246 -0
  77. package/TestFiles/form1_annots.xfdf +34 -0
  78. package/TestFiles/form1_data.fdf +4 -0
  79. package/TestFiles/form1_data.xfdf +140 -0
  80. package/TestFiles/formfields-scanned-withfields.pdf +0 -0
  81. package/TestFiles/formfields-scanned.pdf +0 -0
  82. package/TestFiles/formfields.pdf +0 -0
  83. package/TestFiles/grayscale.tif +0 -0
  84. package/TestFiles/hindi_sample_utf16le.txt +0 -0
  85. package/TestFiles/imagemask.dat +32 -0
  86. package/TestFiles/logo_red.png +0 -0
  87. package/TestFiles/lorem_ipsum.pdf +0 -0
  88. package/TestFiles/multipage.tif +0 -0
  89. package/TestFiles/my_stream.txt +2310 -0
  90. package/TestFiles/newsletter.pdf +0 -0
  91. package/TestFiles/newsletter.xod +0 -0
  92. package/TestFiles/numbered.pdf +0 -0
  93. package/TestFiles/op_blend_test.pdf +1497 -1
  94. package/TestFiles/palm.jp2 +0 -0
  95. package/TestFiles/paragraphs_and_tables.pdf +0 -0
  96. package/TestFiles/pdfnet.gif +0 -0
  97. package/TestFiles/pdftron_smart_substitution.plugin +0 -0
  98. package/TestFiles/peppers.jpg +0 -0
  99. package/TestFiles/signature.jpg +0 -0
  100. package/TestFiles/simple-emf.emf +0 -0
  101. package/TestFiles/simple-excel_2007.xlsx +0 -0
  102. package/TestFiles/simple-outlook.msg +0 -0
  103. package/TestFiles/simple-powerpoint_2007.pptx +0 -0
  104. package/TestFiles/simple-publisher.pub +0 -0
  105. package/TestFiles/simple-rtf.rtf +224 -0
  106. package/TestFiles/simple-text.txt +61 -0
  107. package/TestFiles/simple-visio.vsd +0 -0
  108. package/TestFiles/simple-webpage.html +731 -0
  109. package/TestFiles/simple-webpage.mht +6972 -0
  110. package/TestFiles/simple-webpage_files/colorschememapping.xml +2 -0
  111. package/TestFiles/simple-webpage_files/filelist.xml +14 -0
  112. package/TestFiles/simple-webpage_files/image001.gif +0 -0
  113. package/TestFiles/simple-webpage_files/image002.png +0 -0
  114. package/TestFiles/simple-webpage_files/image003.jpg +0 -0
  115. package/TestFiles/simple-webpage_files/image004.emz +0 -0
  116. package/TestFiles/simple-webpage_files/image005.gif +0 -0
  117. package/TestFiles/simple-webpage_files/image006.png +0 -0
  118. package/TestFiles/simple-webpage_files/image007.gif +0 -0
  119. package/TestFiles/simple-webpage_files/oledata.mso +0 -0
  120. package/TestFiles/simple-webpage_files/themedata.thmx +0 -0
  121. package/TestFiles/simple-word_2007.docx +0 -0
  122. package/TestFiles/simple-xps.xps +0 -0
  123. package/TestFiles/table.pdf +0 -0
  124. package/TestFiles/tagged.pdf +0 -0
  125. package/TestFiles/the_rime_of_the_ancient_mariner.docx +0 -0
  126. package/TestFiles/tiger.pdf +0 -0
  127. package/TestFiles/tiger.svg +378 -0
  128. package/TestFiles/waiver.pdf +0 -0
  129. package/TestFiles/waiver_withApprovalField.pdf +0 -0
  130. package/TestFiles/waiver_withApprovalField_certified.pdf +421 -1
  131. package/TestFiles/waiver_withApprovalField_certified_approved.pdf +465 -1
  132. package/{samples/TextExtractTest → TextExtractTest}/TextExtractTest.js +2 -2
  133. package/{samples/TextSearchTest → TextSearchTest}/TextSearchTest.js +3 -3
  134. package/TransPDFTest/TransPDFTest.js +68 -0
  135. package/{samples/U3DTest → U3DTest}/U3DTest.js +2 -2
  136. package/{samples/UndoRedoTest → UndoRedoTest}/UndoRedoTest.js +2 -2
  137. package/{samples/UnicodeWriteTest → UnicodeWriteTest}/UnicodeWriteTest.js +2 -2
  138. package/{samples/WebViewerConvertTest → WebViewerConvertTest}/WebViewerConvertTest.js +3 -3
  139. package/legal.txt +632 -0
  140. package/license.pdf +0 -0
  141. package/package.json +9 -7
  142. package/readme.md +32 -7
  143. package/runall.bat +12 -0
  144. package/{samples/runall.sh → runall.sh} +5 -4
  145. package/scripts/install.js +68 -0
  146. package/samples/DataExtractionTest/DataExtractionTest.js +0 -180
  147. package/samples/runall.bat +0 -13
package/readme.md CHANGED
@@ -1,13 +1,38 @@
1
- ## @pdftron/pdfnet-node-samples
1
+ ## @pdftron/pdfnet-node
2
2
 
3
- This package contains sample code for [@pdftron/pdfnet-node](https://www.npmjs.com/package/@pdftron/pdfnet-node).
3
+ This package leverages the full power of Apryse's native SDK for maximal performance and accuracy. In order to maintain consistency across platforms the Javascript API is used in the same manner as the PDFNet API available in Apryse's Web platform. Since access to the filesystem is included in Node.js/Electron some additional APIs requiring filesystem access have also been included.
4
4
 
5
- #### Run the samples
6
- Please enter your license key by replacing the LicenseKey variable value in *@pdftron/pdfnet-node-samples/samples/LicenseKey/LicenseKey.js*.
5
+ #### Supported platform, Node.js, and Electron versions
6
+ This package depends on unmanaged add-on binaries, and the add-on binaries are not cross-platform. At the moment we have support for
7
+ * **OS**: Linux, Windows(x64), Mac
8
+ * **Node.js version**: 10 - 24
9
+ * **Electron version**: 30 - 30
10
+
11
+ Installation will fail if your OS, Node.js or Electron version is not supported.
7
12
 
8
- Run `npm run test` in the *@pdftron/pdfnet-node-samples* directory to run all the samples.
13
+ To install for Electron, *runtime* and *target* options are needed. For example, For Electron 6, we need to run *npm i @pdftron/pdfnet-node --runtime=electron --target=6.0.0*. Note that we need to use *6.0.0* for all Electron 6 versions.
9
14
 
10
- The samples are in the *@pdftron/pdfnet-node-samples/samples* directory after the installation for Node.js.
15
+ #### Usage
16
+ Here is a code snippet to demonstrate how to use this package.
17
+ ```javascript
18
+ const { PDFNet } = require('@pdftron/pdfnet-node'); // you may need to set up NODE_PATH environment variable to make this work.
19
+
20
+ const main = async() => {
21
+ const doc = await PDFNet.PDFDoc.create();
22
+ const page = await doc.pageCreate();
23
+ doc.pagePushBack(page);
24
+ doc.save('blank.pdf', PDFNet.SDFDoc.SaveOptions.e_linearized);
25
+ };
26
+
27
+ // add your own license key as the second parameter, e.g. in place of 'YOUR_LICENSE_KEY'.
28
+ PDFNet.runWithCleanup(main, 'YOUR_LICENSE_KEY').catch(function(error) {
29
+ console.log('Error: ' + JSON.stringify(error));
30
+ }).then(function(){ return PDFNet.shutdown(); });
31
+ ```
32
+
33
+ There are some code samples in the [@pdftron/pdfnet-node-samples](https://www.npmjs.com/package/@pdftron/pdfnet-node-samples) package.
34
+
35
+ To get started please see the documentation at https://www.apryse.com/documentation/nodejs/get-started/integration.
11
36
 
12
37
  #### Licensing
13
- Please go to https://www.pdftron.com/pws/get-key to obtain a demo license or https://www.pdftron.com/form/contact-sales to obtain a production key. For further information, please visit https://www.pdftron.com/licensing.
38
+ Please go to https://www.apryse.com/pws/get-key to obtain a demo license or https://wwww.apryse.com/form/contact-sales to obtain a production key. For further information, please visit https://www.apryse.com/licensing.
package/runall.bat ADDED
@@ -0,0 +1,12 @@
1
+ @echo off
2
+ for /D %%s in (*Test) do (
3
+ if exist %%s\%%~nxs.js (
4
+ cd %%s
5
+ echo %%s running...
6
+ call node %%~nxs.js
7
+ cd ..
8
+ echo %%s finished.
9
+ pause
10
+ )
11
+ )
12
+ echo All tests finished.
@@ -2,13 +2,14 @@
2
2
 
3
3
  for SAMPLE in *Test
4
4
  do
5
- if [ -d $SAMPLE/NODEJS ] && [ -e $SAMPLE/NODEJS/RunTest.sh ]
5
+ if [ -d $SAMPLE ] && [ -e $SAMPLE/$SAMPLE.js ]
6
6
  then
7
- cd $SAMPLE/NODEJS
7
+ cd $SAMPLE
8
8
  echo "$SAMPLE running"
9
- sh RunTest.sh
10
- cd ../..
9
+ node $SAMPLE.js
10
+ cd ..
11
11
  echo "$SAMPLE finished. Press enter to continue..."
12
12
  read -p "$*" a
13
13
  fi
14
14
  done
15
+ echo "All tests finished."
@@ -0,0 +1,68 @@
1
+ const { execSync } = require('child_process');
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const pkg = require(path.join(__dirname, '../package.json'));
5
+
6
+ const abi = process.versions.modules; // Node ABI
7
+ const platform = process.platform; // linux, darwin, win32
8
+ const arch = process.arch; // x64, arm64, etc.
9
+ const version = pkg.version;
10
+ const isElectron = !!process.versions.electron;
11
+ const remote_url = "https://downloads.apryse.com/downloads/nodejs"
12
+
13
+ let prebuildUrl = `${remote_url}/${version}/pdfnet-addon-v${version}-node-v${abi}-${platform}-${arch}.tar.gz`;
14
+ if (isElectron) {
15
+ electron_version = process.versions.electron;
16
+ prebuildUrl = `${remote_url}/${version}/pdfnet-addon-v${version}-electron-v${electron_version}-${platform}-${arch}.tar.gz`;
17
+ }
18
+
19
+ console.log('Downloading prebuilt binary from:', prebuildUrl);
20
+
21
+ try {
22
+ execSync(`npx prebuild-install --download ${prebuildUrl} --verbose`, { stdio: 'inherit' });
23
+
24
+ const extractedFolder = `node-v${abi}-${platform}-${arch}`;
25
+ const libFolder = path.join(extractedFolder, 'lib');
26
+ const targetLibFolder = path.join(process.cwd(), 'lib');
27
+
28
+ if (fs.existsSync(libFolder)) {
29
+ if (!fs.existsSync(targetLibFolder)) fs.mkdirSync(targetLibFolder);
30
+
31
+ console.log(`Copying contents of ${libFolder} to ${targetLibFolder}...`);
32
+
33
+ function copyRecursive(src, dest) {
34
+ if (fs.lstatSync(src).isDirectory()) {
35
+ if (!fs.existsSync(dest)) fs.mkdirSync(dest);
36
+ fs.readdirSync(src).forEach(file => {
37
+ copyRecursive(path.join(src, file), path.join(dest, file));
38
+ });
39
+ } else {
40
+ fs.renameSync(src, dest);
41
+ }
42
+ }
43
+
44
+ copyRecursive(libFolder, targetLibFolder);
45
+
46
+ function deleteFolderRecursive(folderPath) {
47
+ if (fs.existsSync(folderPath)) {
48
+ fs.readdirSync(folderPath).forEach(file => {
49
+ const curPath = path.join(folderPath, file);
50
+ if (fs.lstatSync(curPath).isDirectory()) {
51
+ deleteFolderRecursive(curPath);
52
+ } else {
53
+ fs.unlinkSync(curPath);
54
+ }
55
+ });
56
+ fs.rmdirSync(folderPath);
57
+ }
58
+ }
59
+
60
+ deleteFolderRecursive(extractedFolder);
61
+ console.log(`Cleanup complete: removed ${extractedFolder}`);
62
+ } else {
63
+ console.warn(`Lib folder not found at ${libFolder}, skipping move.`);
64
+ }
65
+ } catch (err) {
66
+ console.error('Error during prebuild-install:', err);
67
+ process.exit(1);
68
+ }
@@ -1,180 +0,0 @@
1
- //---------------------------------------------------------------------------------------
2
- // Copyright (c) 2001-2023 by PDFTron Systems Inc. All Rights Reserved.
3
- // Consult legal.txt regarding legal and license information.
4
- //---------------------------------------------------------------------------------------
5
-
6
- //---------------------------------------------------------------------------------------
7
- // The Data Extraction suite is an optional PDFNet add-on collection that can be used to
8
- // extract various types of data from PDF documents.
9
- //
10
- // The PDFTron SDK Data Extraction suite can be downloaded from http://www.pdftron.com/
11
- //---------------------------------------------------------------------------------------
12
-
13
- const fs = require('fs');
14
- const { PDFNet } = require('../lib/pdfnet.js');
15
- const PDFTronLicense = require('../LicenseKey/LicenseKey');
16
-
17
- ((exports) => {
18
- 'use strict';
19
-
20
- exports.runDataExtractionTest = () => {
21
-
22
- const main = async () => {
23
-
24
- const inputPath = '../TestFiles/';
25
- const outputPath = '../TestFiles/Output/';
26
-
27
- //////////////////////////////////////////////////////////////////////////
28
-
29
- await PDFNet.addResourceSearchPath('../lib/');
30
-
31
- //////////////////////////////////////////////////////////////////////////
32
- // The following sample illustrates how to extract tables from PDF documents.
33
- //////////////////////////////////////////////////////////////////////////
34
-
35
- // Test if the add-on is installed
36
- if (!await PDFNet.DataExtractionModule.isModuleAvailable(PDFNet.DataExtractionModule.DataExtractionEngine.e_Tabular)) {
37
- console.log('\nUnable to run Data Extraction: PDFTron SDK Tabular Data module not available.');
38
- console.log('---------------------------------------------------------------');
39
- console.log('The Data Extraction suite is an optional add-on, available for download');
40
- console.log('at https://www.pdftron.com/documentation/core/info/modules/. If you have already');
41
- console.log('downloaded this module, ensure that the SDK is able to find the required files');
42
- console.log('using the PDFNet.addResourceSearchPath() function.\n');
43
- }
44
- else
45
- {
46
- try {
47
- // Extract tabular data as a JSON file
48
- console.log('Extract tabular data as a JSON file');
49
-
50
- let outputFile = outputPath + 'table.json';
51
- await PDFNet.DataExtractionModule.extractData(inputPath + 'table.pdf', outputFile, PDFNet.DataExtractionModule.DataExtractionEngine.e_Tabular);
52
-
53
- console.log('Result saved in ' + outputFile);
54
-
55
- ///////////////////////////////////////////////////////
56
- // Extract tabular data as a JSON string
57
- console.log('Extract tabular data as a JSON string');
58
-
59
- outputFile = outputPath + 'financial.json';
60
- const json = await PDFNet.DataExtractionModule.extractDataAsString(inputPath + 'financial.pdf', PDFNet.DataExtractionModule.DataExtractionEngine.e_Tabular);
61
- fs.writeFileSync(outputFile, json);
62
-
63
- console.log('Result saved in ' + outputFile);
64
-
65
- ///////////////////////////////////////////////////////
66
- // Extract tabular data as an XLSX file
67
- console.log('Extract tabular data as an XLSX file');
68
-
69
- outputFile = outputPath + 'table.xlsx';
70
- await PDFNet.DataExtractionModule.extractToXLSX(inputPath + 'table.pdf', outputFile);
71
-
72
- console.log('Result saved in ' + outputFile);
73
-
74
- ///////////////////////////////////////////////////////
75
- // Extract tabular data as an XLSX stream (also known as filter)
76
- console.log('Extract tabular data as an XLSX stream');
77
-
78
- outputFile = outputPath + 'financial.xlsx';
79
- const outputXlsxStream = await PDFNet.Filter.createMemoryFilter(0, false);
80
- const options = new PDFNet.DataExtractionModule.DataExtractionOptions();
81
- options.setPages("1"); // page 1
82
- await PDFNet.DataExtractionModule.extractToXLSXWithFilter(inputPath + 'financial.pdf', outputXlsxStream, options);
83
- outputXlsxStream.memoryFilterSetAsInputFilter();
84
- outputXlsxStream.writeToFile(outputFile, false);
85
-
86
- console.log('Result saved in ' + outputFile);
87
- } catch (err) {
88
- console.log(err);
89
- }
90
- }
91
-
92
- //////////////////////////////////////////////////////////////////////////
93
- // The following sample illustrates how to extract document structure from PDF documents.
94
- //////////////////////////////////////////////////////////////////////////
95
-
96
- // Test if the add-on is installed
97
- if (!await PDFNet.DataExtractionModule.isModuleAvailable(PDFNet.DataExtractionModule.DataExtractionEngine.e_DocStructure)) {
98
- console.log('\nUnable to run Data Extraction: PDFTron SDK Structured Output module not available.');
99
- console.log('---------------------------------------------------------------');
100
- console.log('The Data Extraction suite is an optional add-on, available for download');
101
- console.log('at https://www.pdftron.com/documentation/core/info/modules/. If you have already');
102
- console.log('downloaded this module, ensure that the SDK is able to find the required files');
103
- console.log('using the PDFNet.addResourceSearchPath() function.\n');
104
- }
105
- else
106
- {
107
- try {
108
- // Extract document structure as a JSON file
109
- console.log('Extract document structure as a JSON file');
110
-
111
- let outputFile = outputPath + 'paragraphs_and_tables.json';
112
- await PDFNet.DataExtractionModule.extractData(inputPath + 'paragraphs_and_tables.pdf', outputFile, PDFNet.DataExtractionModule.DataExtractionEngine.e_DocStructure);
113
-
114
- console.log('Result saved in ' + outputFile);
115
-
116
- ///////////////////////////////////////////////////////
117
- // Extract document structure as a JSON string
118
- console.log('Extract document structure as a JSON string');
119
-
120
- outputFile = outputPath + 'tagged.json';
121
- const json = await PDFNet.DataExtractionModule.extractDataAsString(inputPath + 'tagged.pdf', PDFNet.DataExtractionModule.DataExtractionEngine.e_DocStructure);
122
- fs.writeFileSync(outputFile, json);
123
-
124
- console.log('Result saved in ' + outputFile);
125
- } catch (err) {
126
- console.log(err);
127
- }
128
- }
129
-
130
- //////////////////////////////////////////////////////////////////////////
131
- // The following sample illustrates how to extract form fields from PDF documents.
132
- //////////////////////////////////////////////////////////////////////////
133
-
134
- // Test if the add-on is installed
135
- if (!await PDFNet.DataExtractionModule.isModuleAvailable(PDFNet.DataExtractionModule.DataExtractionEngine.e_Form)) {
136
- console.log('\nUnable to run Data Extraction: PDFTron SDK AIFormFieldExtractor module not available.');
137
- console.log('---------------------------------------------------------------');
138
- console.log('The Data Extraction suite is an optional add-on, available for download');
139
- console.log('at https://www.pdftron.com/documentation/core/info/modules/. If you have already');
140
- console.log('downloaded this module, ensure that the SDK is able to find the required files');
141
- console.log('using the PDFNet.addResourceSearchPath() function.\n');
142
- }
143
- else
144
- {
145
- try {
146
- // Extract form fields as a JSON file
147
- console.log('Extract form fields as a JSON file');
148
-
149
- let outputFile = outputPath + 'formfields-scanned.json';
150
- await PDFNet.DataExtractionModule.extractData(inputPath + 'formfields-scanned.pdf', outputFile, PDFNet.DataExtractionModule.DataExtractionEngine.e_Form);
151
-
152
- console.log('Result saved in ' + outputFile);
153
-
154
- ///////////////////////////////////////////////////////
155
- // Extract form fields as a JSON string
156
- console.log('Extract form fields as a JSON string');
157
-
158
- outputFile = outputPath + 'formfields.json';
159
- const json = await PDFNet.DataExtractionModule.extractDataAsString(inputPath + 'formfields.pdf', PDFNet.DataExtractionModule.DataExtractionEngine.e_Form);
160
- fs.writeFileSync(outputFile, json);
161
-
162
- console.log('Result saved in ' + outputFile);
163
- } catch (err) {
164
- console.log(err);
165
- }
166
- }
167
-
168
- //////////////////////////////////////////////////////////////////////////
169
-
170
- console.log('Done.');
171
- };
172
-
173
- PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) {
174
- console.log('Error: ' + JSON.stringify(error));
175
- }).then(function () { return PDFNet.shutdown(); });
176
- };
177
- exports.runDataExtractionTest();
178
- })(exports);
179
- // eslint-disable-next-line spaced-comment
180
- //# sourceURL=DataExtractionTest.js
@@ -1,13 +0,0 @@
1
- @echo off
2
- for /D %%s in (*Test) do (
3
- if exist %%s\NODEJS\%%~nxs.js (
4
- cd %%s\NODEJS
5
- echo %%s starting...
6
- call node %%~nxs.js
7
- cd ..\..
8
- echo %%s finished.
9
- pause
10
- )
11
- )
12
-
13
- echo Run all tests finished.