@pdftron/pdfnet-node-samples 10.5.0 → 10.6.0-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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pdftron/pdfnet-node-samples",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.6.0-beta",
|
|
4
4
|
"description": "Sample code for the @pdftron/pdfnet-node package.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "run-script-os",
|
|
@@ -12,8 +12,7 @@
|
|
|
12
12
|
"license": "Commercial",
|
|
13
13
|
"homepage": "https://www.pdftron.com",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@pdftron/pdfnet-node": "~10.
|
|
15
|
+
"@pdftron/pdfnet-node": "~10.6.0-beta",
|
|
16
16
|
"run-script-os": "^1.1.6"
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
|
|
@@ -160,6 +160,40 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
160
160
|
fs.writeFileSync(outputFile, json);
|
|
161
161
|
|
|
162
162
|
console.log('Result saved in ' + outputFile);
|
|
163
|
+
|
|
164
|
+
//////////////////////////////////////////////////////////////////////////
|
|
165
|
+
// Detect and add form fields to a PDF document.
|
|
166
|
+
// Document already has form fields, and this sample will update to new found fields.
|
|
167
|
+
{
|
|
168
|
+
console.log('Detect and add form fields in a PDF file, keep new fields');
|
|
169
|
+
|
|
170
|
+
const doc = await PDFNet.PDFDoc.createFromFilePath(inputPath + "formfields-scanned-withfields.pdf");
|
|
171
|
+
|
|
172
|
+
await PDFNet.DataExtractionModule.detectAndAddFormFieldsToPDF(doc);
|
|
173
|
+
outputFile = outputPath + 'formfields-scanned-fields-new.pdf';
|
|
174
|
+
await doc.save(outputFile, PDFNet.SDFDoc.SaveOptions.e_linearized);
|
|
175
|
+
|
|
176
|
+
console.log('Result saved in ' + outputFile);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
//////////////////////////////////////////////////////////////////////////
|
|
180
|
+
// Detect and add form fields to a PDF document.
|
|
181
|
+
// Document already has form fields, and this sample will keep the original fields.
|
|
182
|
+
{
|
|
183
|
+
console.log('Detect and add form fields in a PDF file, keep old fields');
|
|
184
|
+
|
|
185
|
+
const doc = await PDFNet.PDFDoc.createFromFilePath(inputPath + "formfields-scanned-withfields.pdf");
|
|
186
|
+
|
|
187
|
+
const options = new PDFNet.DataExtractionModule.DataExtractionOptions();
|
|
188
|
+
options.setOverlappingFormFieldBehavior('KeepOld');
|
|
189
|
+
|
|
190
|
+
await PDFNet.DataExtractionModule.detectAndAddFormFieldsToPDF(doc, options);
|
|
191
|
+
outputFile = outputPath + 'formfields-scanned-fields-old.pdf';
|
|
192
|
+
await doc.save(outputFile, PDFNet.SDFDoc.SaveOptions.e_linearized);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
console.log('Result saved in ' + outputFile);
|
|
196
|
+
|
|
163
197
|
} catch (err) {
|
|
164
198
|
console.log(err);
|
|
165
199
|
}
|
|
Binary file
|