@pdftron/pdfnet-node-samples 9.1.0 → 9.2.0-1
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 +18 -18
- package/readme.md +5 -3
- package/samples/AddImageTest/AddImageTest.js +1 -1
- package/samples/AdvancedImagingTest/AdvancedImagingTest.js +1 -1
- package/samples/AnnotationTest/AnnotationTest.js +1 -1
- package/samples/BookmarkTest/BookmarkTest.js +1 -1
- package/samples/CAD2PDFTest/CAD2PDFTest.js +2 -2
- package/samples/ContentReplacerTest/ContentReplacerTest.js +1 -1
- package/samples/ConvertTest/ConvertTest.js +1 -1
- package/samples/DigitalSignaturesTest/DigitalSignaturesTest.js +1 -1
- package/samples/ElementBuilderTest/ElementBuilderTest.js +1 -1
- package/samples/ElementEditTest/ElementEditTest.js +1 -1
- package/samples/ElementReaderAdvTest/ElementReaderAdvTest.js +1 -1
- package/samples/ElementReaderTest/ElementReaderTest.js +1 -1
- package/samples/EncTest/EncTest.js +1 -1
- package/samples/FDFTest/FDFTest.js +1 -1
- package/samples/HTML2PDFTest/HTML2PDFTest.js +1 -1
- package/samples/ImageExtractTest/ImageExtractTest.js +1 -1
- package/samples/ImpositionTest/ImpositionTest.js +1 -1
- package/samples/InteractiveFormsTest/InteractiveFormsTest.js +1 -1
- package/samples/JBIG2Test/JBIG2Test.js +2 -2
- package/samples/LogicalStructureTest/LogicalStructureTest.js +1 -1
- package/samples/OCRTest/OCRTest.js +1 -1
- package/samples/OfficeToPDFTest/OfficeToPDFTest.js +1 -1
- package/samples/OptimizerTest/OptimizerTest.js +1 -1
- package/samples/PDF2HtmlTest/PDF2HtmlTest.js +28 -22
- package/samples/PDF2OfficeTest/PDF2OfficeTest.js +158 -0
- package/samples/PDF2OfficeTest/RunTest.bat +2 -0
- package/samples/PDF2OfficeTest/RunTest.sh +2 -0
- package/samples/PDFATest/PDFATest.js +1 -1
- package/samples/PDFDocMemoryTest/PDFDocMemoryTest.js +1 -1
- package/samples/PDFDrawTest/PDFDrawTest.js +1 -1
- package/samples/PDFLayersTest/PDFLayersTest.js +1 -1
- package/samples/PDFPackageTest/PDFPackageTest.js +2 -2
- package/samples/PDFPageTest/PDFPageTest.js +1 -1
- package/samples/PDFRedactTest/PDFRedactTest.js +1 -1
- package/samples/PageLabelsTest/PageLabelsTest.js +1 -1
- package/samples/PatternTest/PatternTest.js +1 -1
- package/samples/RectTest/RectTest.js +1 -1
- package/samples/SDFTest/SDFTest.js +1 -1
- package/samples/StamperTest/StamperTest.js +1 -1
- package/samples/TextExtractTest/TextExtractTest.js +1 -1
- package/samples/TextSearchTest/TextSearchTest.js +1 -1
- package/samples/U3DTest/U3DTest.js +1 -1
- package/samples/UndoRedoTest/UndoRedoTest.js +1 -1
- package/samples/UnicodeWriteTest/UnicodeWriteTest.js +1 -1
- package/samples/WebViewerConvertTest/WebViewerConvertTest.js +1 -1
- package/samples/PDF2WordTest/PDF2WordTest.js +0 -85
- package/samples/PDF2WordTest/RunTest.bat +0 -2
- package/samples/PDF2WordTest/RunTest.sh +0 -2
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@pdftron/pdfnet-node-samples",
|
|
3
|
-
"version": "9.
|
|
4
|
-
"description": "Sample code for the @pdftron/pdfnet-node package.",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"test": "run-script-os",
|
|
7
|
-
"test:darwin:linux": "cd samples && sh runall.sh",
|
|
8
|
-
"test:win32": "cd samples && runall.bat",
|
|
9
|
-
|
|
10
|
-
},
|
|
11
|
-
"author": "PDFTron Systems Inc.",
|
|
12
|
-
"license": "Commercial",
|
|
13
|
-
"homepage": "https://www.pdftron.com",
|
|
14
|
-
"dependencies": {
|
|
15
|
-
"@pdftron/pdfnet-node": "9.
|
|
16
|
-
"run-script-os": "^1.1.6"
|
|
17
|
-
}
|
|
18
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@pdftron/pdfnet-node-samples",
|
|
3
|
+
"version": "9.2.0-1",
|
|
4
|
+
"description": "Sample code for the @pdftron/pdfnet-node package.",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"test": "run-script-os",
|
|
7
|
+
"test:darwin:linux": "cd samples && sh runall.sh",
|
|
8
|
+
"test:win32": "cd samples && runall.bat",
|
|
9
|
+
"test:default": "echo '@pdftron/pdfnet-node doesn't support this platform.'"
|
|
10
|
+
},
|
|
11
|
+
"author": "PDFTron Systems Inc.",
|
|
12
|
+
"license": "Commercial",
|
|
13
|
+
"homepage": "https://www.pdftron.com",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@pdftron/pdfnet-node": "9.2.0",
|
|
16
|
+
"run-script-os": "^1.1.6"
|
|
17
|
+
}
|
|
18
|
+
}
|
package/readme.md
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
## @pdftron/pdfnet-node-samples
|
|
2
2
|
|
|
3
|
-
This package contains sample code for @pdftron/pdfnet-node.
|
|
3
|
+
This package contains sample code for [@pdftron/pdfnet-node](https://www.npmjs.com/package/@pdftron/pdfnet-node).
|
|
4
4
|
|
|
5
5
|
#### Run the samples
|
|
6
|
-
|
|
6
|
+
Please enter your license key by replacing the LicenseKey variable value in *@pdftron/pdfnet-node-samples/samples/LicenseKey/LicenseKey.js*.
|
|
7
|
+
|
|
8
|
+
Run `npm run test` in the *@pdftron/pdfnet-node-samples* directory to run all the samples.
|
|
7
9
|
|
|
8
10
|
The samples are in the *@pdftron/pdfnet-node-samples/samples* directory after the installation for Node.js.
|
|
9
11
|
|
|
10
12
|
#### Licensing
|
|
11
|
-
|
|
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.
|
|
@@ -108,7 +108,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
108
108
|
console.log(err);
|
|
109
109
|
}
|
|
110
110
|
};
|
|
111
|
-
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error){console.log('Error: ' + JSON.stringify(error));}).then(function(){PDFNet.shutdown();});
|
|
111
|
+
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error){console.log('Error: ' + JSON.stringify(error));}).then(function(){return PDFNet.shutdown();});
|
|
112
112
|
};
|
|
113
113
|
exports.runAddImageTest();
|
|
114
114
|
})(exports);
|
|
@@ -56,7 +56,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
56
56
|
};
|
|
57
57
|
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) {
|
|
58
58
|
console.log('Error: ' + JSON.stringify(error));
|
|
59
|
-
}).then(function () { PDFNet.shutdown(); });
|
|
59
|
+
}).then(function () { return PDFNet.shutdown(); });
|
|
60
60
|
};
|
|
61
61
|
exports.runAdvancedImagingTest();
|
|
62
62
|
})(exports);
|
|
@@ -634,7 +634,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
634
634
|
console.log(err);
|
|
635
635
|
}
|
|
636
636
|
};
|
|
637
|
-
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error){console.log('Error: ' + JSON.stringify(error));}).then(function(){PDFNet.shutdown();});
|
|
637
|
+
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error){console.log('Error: ' + JSON.stringify(error));}).then(function(){return PDFNet.shutdown();});
|
|
638
638
|
};
|
|
639
639
|
exports.runAnnotationTest();
|
|
640
640
|
})(exports);
|
|
@@ -212,7 +212,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
212
212
|
};
|
|
213
213
|
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) {
|
|
214
214
|
console.log('Error: ' + JSON.stringify(error));
|
|
215
|
-
}).then(function () { PDFNet.shutdown(); });
|
|
215
|
+
}).then(function () { return PDFNet.shutdown(); });
|
|
216
216
|
};
|
|
217
217
|
exports.runBookmarkTest();
|
|
218
218
|
})(exports);
|
|
@@ -22,7 +22,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
22
22
|
|
|
23
23
|
exports.runCAD2PDFTest = () => {
|
|
24
24
|
const IsRVTFile = function (inputFile) {
|
|
25
|
-
|
|
25
|
+
let rvt_input = false;
|
|
26
26
|
if (inputFile.length > 2) {
|
|
27
27
|
if (inputFile.substr(inputFile.length - 3, 3) === 'rvt') {
|
|
28
28
|
rvt_input = true;
|
|
@@ -72,7 +72,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
72
72
|
};
|
|
73
73
|
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error) {
|
|
74
74
|
console.log('Error: ' + JSON.stringify(error));
|
|
75
|
-
}).then(function(){ PDFNet.shutdown(); });
|
|
75
|
+
}).then(function(){ return PDFNet.shutdown(); });
|
|
76
76
|
};
|
|
77
77
|
exports.runCAD2PDFTest();
|
|
78
78
|
})(exports);
|
|
@@ -67,7 +67,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
67
67
|
}
|
|
68
68
|
console.log('Done.');
|
|
69
69
|
};
|
|
70
|
-
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error){console.log('Error: ' + JSON.stringify(error));}).then(function(){PDFNet.shutdown();});
|
|
70
|
+
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error){console.log('Error: ' + JSON.stringify(error));}).then(function(){return PDFNet.shutdown();});
|
|
71
71
|
};
|
|
72
72
|
exports.runContentReplacer();
|
|
73
73
|
})(exports);
|
|
@@ -248,7 +248,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
248
248
|
};
|
|
249
249
|
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error) {
|
|
250
250
|
console.log('Error: ' + JSON.stringify(error));
|
|
251
|
-
}).then(function(){ PDFNet.shutdown(); });
|
|
251
|
+
}).then(function(){ return PDFNet.shutdown(); });
|
|
252
252
|
};
|
|
253
253
|
exports.runConvertTest();
|
|
254
254
|
})(exports);
|
|
@@ -519,7 +519,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
519
519
|
|
|
520
520
|
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) {
|
|
521
521
|
console.log('Error: ' + JSON.stringify(error));
|
|
522
|
-
}).then(function () { PDFNet.shutdown(); });
|
|
522
|
+
}).then(function () { return PDFNet.shutdown(); });
|
|
523
523
|
};
|
|
524
524
|
exports.runDigitalSignatureTest();
|
|
525
525
|
})(exports);
|
|
@@ -506,7 +506,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
506
506
|
return ret;
|
|
507
507
|
};
|
|
508
508
|
|
|
509
|
-
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error){console.log('Error: ' + JSON.stringify(error));}).then(function(){PDFNet.shutdown();});
|
|
509
|
+
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error){console.log('Error: ' + JSON.stringify(error));}).then(function(){return PDFNet.shutdown();});
|
|
510
510
|
};
|
|
511
511
|
exports.runElementBuilderTest();
|
|
512
512
|
})(exports);
|
|
@@ -103,7 +103,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
103
103
|
}
|
|
104
104
|
};
|
|
105
105
|
|
|
106
|
-
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) { console.log('Error: ' + JSON.stringify(error)); }).then(function () { PDFNet.shutdown(); });
|
|
106
|
+
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) { console.log('Error: ' + JSON.stringify(error)); }).then(function () { return PDFNet.shutdown(); });
|
|
107
107
|
};
|
|
108
108
|
exports.runElementEditTest();
|
|
109
109
|
})(exports);
|
|
@@ -297,7 +297,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
297
297
|
console.log(err);
|
|
298
298
|
}
|
|
299
299
|
};
|
|
300
|
-
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) { console.log('Error: ' + JSON.stringify(error)); }).then(function () { PDFNet.shutdown(); });
|
|
300
|
+
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) { console.log('Error: ' + JSON.stringify(error)); }).then(function () { return PDFNet.shutdown(); });
|
|
301
301
|
};
|
|
302
302
|
exports.runElementReaderAdvTest();
|
|
303
303
|
})(exports);
|
|
@@ -69,7 +69,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
69
69
|
console.log('Done.');
|
|
70
70
|
return ret;
|
|
71
71
|
};
|
|
72
|
-
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error){console.log('Error: ' + JSON.stringify(error));}).then(function(){PDFNet.shutdown();});
|
|
72
|
+
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error){console.log('Error: ' + JSON.stringify(error));}).then(function(){return PDFNet.shutdown();});
|
|
73
73
|
};
|
|
74
74
|
exports.runElementReaderTest();
|
|
75
75
|
})(exports);
|
|
@@ -168,7 +168,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
168
168
|
return ret;
|
|
169
169
|
};
|
|
170
170
|
|
|
171
|
-
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) { console.log('Error: ' + JSON.stringify(error)); }).then(function () { PDFNet.shutdown(); });
|
|
171
|
+
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) { console.log('Error: ' + JSON.stringify(error)); }).then(function () { return PDFNet.shutdown(); });
|
|
172
172
|
};
|
|
173
173
|
exports.runEncTest();
|
|
174
174
|
})(exports);
|
|
@@ -211,7 +211,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
211
211
|
}
|
|
212
212
|
};
|
|
213
213
|
|
|
214
|
-
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) { console.log('Error: ' + JSON.stringify(error)); }).then(function () { PDFNet.shutdown(); });
|
|
214
|
+
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) { console.log('Error: ' + JSON.stringify(error)); }).then(function () { return PDFNet.shutdown(); });
|
|
215
215
|
};
|
|
216
216
|
exports.runFDFTest();
|
|
217
217
|
})(exports);
|
|
@@ -150,7 +150,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
150
150
|
}
|
|
151
151
|
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error) {
|
|
152
152
|
console.log('Error: ' + JSON.stringify(error));
|
|
153
|
-
}).then(function(){ PDFNet.shutdown(); });
|
|
153
|
+
}).then(function(){ return PDFNet.shutdown(); });
|
|
154
154
|
};
|
|
155
155
|
exports.runHTML2PDFTest();
|
|
156
156
|
})(exports);
|
|
@@ -122,7 +122,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
122
122
|
}
|
|
123
123
|
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error) {
|
|
124
124
|
console.log('Error: ' + JSON.stringify(error));
|
|
125
|
-
}).then(function(){ PDFNet.shutdown(); });
|
|
125
|
+
}).then(function(){ return PDFNet.shutdown(); });
|
|
126
126
|
};
|
|
127
127
|
exports.runImageExtractTest();
|
|
128
128
|
})(exports);
|
|
@@ -79,7 +79,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
79
79
|
}
|
|
80
80
|
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error) {
|
|
81
81
|
console.log('Error: ' + JSON.stringify(error));
|
|
82
|
-
}).then(function(){ PDFNet.shutdown(); });
|
|
82
|
+
}).then(function(){ return PDFNet.shutdown(); });
|
|
83
83
|
};
|
|
84
84
|
exports.runImpositionTest();
|
|
85
85
|
})(exports);
|
|
@@ -374,7 +374,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
374
374
|
};
|
|
375
375
|
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) {
|
|
376
376
|
console.log('Error: ' + JSON.stringify(error));
|
|
377
|
-
}).then(function () { PDFNet.shutdown(); });
|
|
377
|
+
}).then(function () { return PDFNet.shutdown(); });
|
|
378
378
|
};
|
|
379
379
|
exports.runInteractiveFormsTest();
|
|
380
380
|
})(exports);
|
|
@@ -30,7 +30,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
30
30
|
const obj = await cos_doc.getObj(i);
|
|
31
31
|
if (obj && !(await obj.isFree()) && await obj.isStream()) {
|
|
32
32
|
// Process only images
|
|
33
|
-
|
|
33
|
+
let itr = await obj.find('Subtype');
|
|
34
34
|
if (!(await itr.hasNext()) || await (await itr.value()).getName() !== 'Image')
|
|
35
35
|
continue;
|
|
36
36
|
const input_image = await PDFNet.Image.createFromObj(obj);
|
|
@@ -81,7 +81,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
81
81
|
};
|
|
82
82
|
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error) {
|
|
83
83
|
console.log('Error: ' + JSON.stringify(error));
|
|
84
|
-
}).then(function(){ PDFNet.shutdown(); });
|
|
84
|
+
}).then(function(){ return PDFNet.shutdown(); });
|
|
85
85
|
};
|
|
86
86
|
exports.runJBIG2Test();
|
|
87
87
|
})(exports);
|
|
@@ -243,7 +243,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
243
243
|
}
|
|
244
244
|
};
|
|
245
245
|
|
|
246
|
-
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error){console.log('Error: ' + JSON.stringify(error));}).then(function(){PDFNet.shutdown();});
|
|
246
|
+
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error){console.log('Error: ' + JSON.stringify(error));}).then(function(){return PDFNet.shutdown();});
|
|
247
247
|
};
|
|
248
248
|
exports.runLogicalStructureTest();
|
|
249
249
|
})(exports);
|
|
@@ -242,7 +242,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
242
242
|
};
|
|
243
243
|
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error) {
|
|
244
244
|
console.log('Error: ' + JSON.stringify(error));
|
|
245
|
-
}).then(function(){ PDFNet.shutdown(); });
|
|
245
|
+
}).then(function(){ return PDFNet.shutdown(); });
|
|
246
246
|
};
|
|
247
247
|
exports.runOCRTest();
|
|
248
248
|
})(exports);
|
|
@@ -116,7 +116,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
116
116
|
|
|
117
117
|
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) {
|
|
118
118
|
console.log('Error: ' + JSON.stringify(error));
|
|
119
|
-
}).then(function () { PDFNet.shutdown(); });
|
|
119
|
+
}).then(function () { return PDFNet.shutdown(); });
|
|
120
120
|
|
|
121
121
|
};
|
|
122
122
|
exports.runOfficeToPDF();
|
|
@@ -184,7 +184,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
184
184
|
};
|
|
185
185
|
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) {
|
|
186
186
|
console.log('Error: ' + JSON.stringify(error));
|
|
187
|
-
}).then(function () { PDFNet.shutdown(); });
|
|
187
|
+
}).then(function () { return PDFNet.shutdown(); });
|
|
188
188
|
};
|
|
189
189
|
exports.runOptimizerTest();
|
|
190
190
|
})(exports);
|
|
@@ -10,10 +10,11 @@
|
|
|
10
10
|
// There are two HTML modules and one of them is an optional PDFNet Add-on.
|
|
11
11
|
// 1. The built-in HTML module is used to convert PDF documents to fixed-position HTML
|
|
12
12
|
// documents.
|
|
13
|
-
// 2. The optional add-on module is used to convert PDF documents to
|
|
14
|
-
// text flowing
|
|
13
|
+
// 2. The optional Structured Output add-on module is used to convert PDF documents to
|
|
14
|
+
// HTML documents with text flowing across the browser window.
|
|
15
15
|
//
|
|
16
|
-
// The PDFTron SDK
|
|
16
|
+
// The PDFTron SDK Structured Output module can be downloaded from
|
|
17
|
+
// https://www.pdftron.com/documentation/core/info/modules/
|
|
17
18
|
//
|
|
18
19
|
// Please contact us if you have any questions.
|
|
19
20
|
//---------------------------------------------------------------------------------------
|
|
@@ -30,6 +31,9 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
30
31
|
|
|
31
32
|
const inputPath = '../TestFiles/';
|
|
32
33
|
const outputPath = '../TestFiles/Output/';
|
|
34
|
+
|
|
35
|
+
//////////////////////////////////////////////////////////////////////////
|
|
36
|
+
|
|
33
37
|
try {
|
|
34
38
|
// Convert PDF document to HTML with fixed positioning option turned on (default)
|
|
35
39
|
console.log('Converting PDF to HTML with fixed positioning option turned on (default)');
|
|
@@ -48,13 +52,12 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
48
52
|
|
|
49
53
|
await PDFNet.addResourceSearchPath('../../lib/');
|
|
50
54
|
|
|
51
|
-
if (!await PDFNet.
|
|
52
|
-
|
|
53
|
-
console.log('\nUnable to run part of the sample: PDFTron SDK HTML reflow paragraphs module not available.');
|
|
55
|
+
if (!await PDFNet.StructuredOutputModule.isModuleAvailable()) {
|
|
56
|
+
console.log('\nUnable to run part of the sample: PDFTron SDK Structured Output module not available.');
|
|
54
57
|
console.log('---------------------------------------------------------------');
|
|
55
|
-
console.log('The
|
|
56
|
-
console.log('at
|
|
57
|
-
console.log('module, ensure that the SDK is able to find the required files');
|
|
58
|
+
console.log('The Structured Output module is an optional add-on, available for download');
|
|
59
|
+
console.log('at https://www.pdftron.com/documentation/core/info/modules/. If you have already');
|
|
60
|
+
console.log('downloaded this module, ensure that the SDK is able to find the required files');
|
|
58
61
|
console.log('using the PDFNet::AddResourceSearchPath() function.\n');
|
|
59
62
|
|
|
60
63
|
return;
|
|
@@ -63,15 +66,15 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
63
66
|
//////////////////////////////////////////////////////////////////////////
|
|
64
67
|
|
|
65
68
|
try {
|
|
66
|
-
// Convert PDF document to HTML with reflow
|
|
67
|
-
console.log('Converting PDF to HTML with reflow
|
|
69
|
+
// Convert PDF document to HTML with reflow full option turned on (1)
|
|
70
|
+
console.log('Converting PDF to HTML with reflow full option turned on (1)');
|
|
68
71
|
|
|
69
|
-
const outputFile = outputPath + '
|
|
72
|
+
const outputFile = outputPath + 'paragraphs_and_tables_reflow_full.html';
|
|
70
73
|
|
|
71
74
|
const htmlOutputOptions = new PDFNet.Convert.HTMLOutputOptions();
|
|
72
75
|
|
|
73
|
-
// Set
|
|
74
|
-
htmlOutputOptions.setContentReflowSetting(PDFNet.Convert.HTMLOutputOptions.ContentReflowSetting.
|
|
76
|
+
// Set e_reflow_full content reflow setting
|
|
77
|
+
htmlOutputOptions.setContentReflowSetting(PDFNet.Convert.HTMLOutputOptions.ContentReflowSetting.e_reflow_full);
|
|
75
78
|
|
|
76
79
|
// Convert PDF to HTML
|
|
77
80
|
await PDFNet.Convert.fileToHtml(inputPath + 'paragraphs_and_tables.pdf', outputFile, htmlOutputOptions);
|
|
@@ -84,18 +87,18 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
84
87
|
//////////////////////////////////////////////////////////////////////////
|
|
85
88
|
|
|
86
89
|
try {
|
|
87
|
-
// Convert PDF document to HTML with reflow
|
|
88
|
-
console.log('Converting PDF to HTML with reflow
|
|
90
|
+
// Convert PDF document to HTML with reflow full option turned on (only converting the first page) (2)
|
|
91
|
+
console.log('Converting PDF to HTML with reflow full option turned on (only converting the first page) (2)');
|
|
89
92
|
|
|
90
|
-
const outputFile = outputPath + '
|
|
93
|
+
const outputFile = outputPath + 'paragraphs_and_tables_reflow_full_first_page.html';
|
|
91
94
|
|
|
92
95
|
const htmlOutputOptions = new PDFNet.Convert.HTMLOutputOptions();
|
|
93
96
|
|
|
94
|
-
// Set
|
|
95
|
-
htmlOutputOptions.setContentReflowSetting(PDFNet.Convert.HTMLOutputOptions.ContentReflowSetting.
|
|
97
|
+
// Set e_reflow_full content reflow setting
|
|
98
|
+
htmlOutputOptions.setContentReflowSetting(PDFNet.Convert.HTMLOutputOptions.ContentReflowSetting.e_reflow_full);
|
|
96
99
|
|
|
97
|
-
//
|
|
98
|
-
htmlOutputOptions.
|
|
100
|
+
// Convert only the first page
|
|
101
|
+
htmlOutputOptions.setPages(1, 1);
|
|
99
102
|
|
|
100
103
|
// Convert PDF to HTML
|
|
101
104
|
await PDFNet.Convert.fileToHtml(inputPath + 'paragraphs_and_tables.pdf', outputFile, htmlOutputOptions);
|
|
@@ -105,11 +108,14 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
105
108
|
console.log(err);
|
|
106
109
|
}
|
|
107
110
|
|
|
111
|
+
//////////////////////////////////////////////////////////////////////////
|
|
112
|
+
|
|
108
113
|
console.log('Done.');
|
|
109
114
|
};
|
|
115
|
+
|
|
110
116
|
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) {
|
|
111
117
|
console.log('Error: ' + JSON.stringify(error));
|
|
112
|
-
}).then(function () { PDFNet.shutdown(); });
|
|
118
|
+
}).then(function () { return PDFNet.shutdown(); });
|
|
113
119
|
};
|
|
114
120
|
exports.runPDF2HtmlTest();
|
|
115
121
|
})(exports);
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
//---------------------------------------------------------------------------------------
|
|
2
|
+
// Copyright (c) 2001-2021 by PDFTron Systems Inc. All Rights Reserved.
|
|
3
|
+
// Consult legal.txt regarding legal and license information.
|
|
4
|
+
//---------------------------------------------------------------------------------------
|
|
5
|
+
|
|
6
|
+
//---------------------------------------------------------------------------------------
|
|
7
|
+
// The following sample illustrates how to use the PDF::Convert utility class to convert
|
|
8
|
+
// documents and files to Word, Excel and PowerPoint.
|
|
9
|
+
//
|
|
10
|
+
// The Structured Output module is an optional PDFNet Add-on that can be used to convert PDF
|
|
11
|
+
// and other documents into Word, Excel, PowerPoint and HTML format.
|
|
12
|
+
//
|
|
13
|
+
// The PDFTron SDK Structured Output module can be downloaded from
|
|
14
|
+
// https://www.pdftron.com/documentation/core/info/modules/
|
|
15
|
+
//
|
|
16
|
+
// Please contact us if you have any questions.
|
|
17
|
+
//---------------------------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
const { PDFNet } = require('@pdftron/pdfnet-node');
|
|
20
|
+
const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
21
|
+
|
|
22
|
+
((exports) => {
|
|
23
|
+
'use strict';
|
|
24
|
+
|
|
25
|
+
exports.runPDF2OfficeTest = () => {
|
|
26
|
+
|
|
27
|
+
const main = async () => {
|
|
28
|
+
|
|
29
|
+
const inputPath = '../TestFiles/';
|
|
30
|
+
const outputPath = '../TestFiles/Output/';
|
|
31
|
+
|
|
32
|
+
//////////////////////////////////////////////////////////////////////////
|
|
33
|
+
|
|
34
|
+
await PDFNet.addResourceSearchPath('../../lib/');
|
|
35
|
+
|
|
36
|
+
if (!await PDFNet.StructuredOutputModule.isModuleAvailable()) {
|
|
37
|
+
console.log('\nUnable to run the sample: PDFTron SDK Structured Output module not available.');
|
|
38
|
+
console.log('---------------------------------------------------------------');
|
|
39
|
+
console.log('The Structured Output module 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
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//////////////////////////////////////////////////////////////////////////
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
// Convert PDF document to Word
|
|
51
|
+
console.log('Converting PDF to Word');
|
|
52
|
+
|
|
53
|
+
const outputFile = outputPath + 'paragraphs_and_tables.docx';
|
|
54
|
+
|
|
55
|
+
await PDFNet.Convert.fileToWord(inputPath + 'paragraphs_and_tables.pdf', outputFile);
|
|
56
|
+
|
|
57
|
+
console.log('Result saved in ' + outputFile);
|
|
58
|
+
} catch (err) {
|
|
59
|
+
console.log(err);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
try {
|
|
63
|
+
// Convert PDF document to Word with options
|
|
64
|
+
console.log('Converting PDF to Word with options');
|
|
65
|
+
|
|
66
|
+
const outputFile = outputPath + 'paragraphs_and_tables_first_page.docx';
|
|
67
|
+
|
|
68
|
+
const wordOutputOptions = new PDFNet.Convert.WordOutputOptions();
|
|
69
|
+
|
|
70
|
+
// Convert only the first page
|
|
71
|
+
wordOutputOptions.setPages(1, 1);
|
|
72
|
+
|
|
73
|
+
await PDFNet.Convert.fileToWord(inputPath + 'paragraphs_and_tables.pdf', outputFile, wordOutputOptions);
|
|
74
|
+
|
|
75
|
+
console.log('Result saved in ' + outputFile);
|
|
76
|
+
} catch (err) {
|
|
77
|
+
console.log(err);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
//////////////////////////////////////////////////////////////////////////
|
|
81
|
+
|
|
82
|
+
try {
|
|
83
|
+
// Convert PDF document to Excel
|
|
84
|
+
console.log('Converting PDF to Excel');
|
|
85
|
+
|
|
86
|
+
const outputFile = outputPath + 'paragraphs_and_tables.xlsx';
|
|
87
|
+
|
|
88
|
+
await PDFNet.Convert.fileToExcel(inputPath + 'paragraphs_and_tables.pdf', outputFile);
|
|
89
|
+
|
|
90
|
+
console.log('Result saved in ' + outputFile);
|
|
91
|
+
} catch (err) {
|
|
92
|
+
console.log(err);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
try {
|
|
96
|
+
// Convert PDF document to Excel with options
|
|
97
|
+
console.log('Converting PDF to Excel with options');
|
|
98
|
+
|
|
99
|
+
const outputFile = outputPath + 'paragraphs_and_tables_second_page.xlsx';
|
|
100
|
+
|
|
101
|
+
const excelOutputOptions = new PDFNet.Convert.ExcelOutputOptions();
|
|
102
|
+
|
|
103
|
+
// Convert only the second page
|
|
104
|
+
excelOutputOptions.setPages(2, 2);
|
|
105
|
+
|
|
106
|
+
await PDFNet.Convert.fileToExcel(inputPath + 'paragraphs_and_tables.pdf', outputFile, excelOutputOptions);
|
|
107
|
+
|
|
108
|
+
console.log('Result saved in ' + outputFile);
|
|
109
|
+
} catch (err) {
|
|
110
|
+
console.log(err);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
//////////////////////////////////////////////////////////////////////////
|
|
114
|
+
|
|
115
|
+
try {
|
|
116
|
+
// Convert PDF document to PowerPoint
|
|
117
|
+
console.log('Converting PDF to PowerPoint');
|
|
118
|
+
|
|
119
|
+
const outputFile = outputPath + 'paragraphs_and_tables.pptx';
|
|
120
|
+
|
|
121
|
+
await PDFNet.Convert.fileToPowerPoint(inputPath + 'paragraphs_and_tables.pdf', outputFile);
|
|
122
|
+
|
|
123
|
+
console.log('Result saved in ' + outputFile);
|
|
124
|
+
} catch (err) {
|
|
125
|
+
console.log(err);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
try {
|
|
129
|
+
// Convert PDF document to PowerPoint with options
|
|
130
|
+
console.log('Converting PDF to PowerPoint with options');
|
|
131
|
+
|
|
132
|
+
const outputFile = outputPath + 'paragraphs_and_tables_first_page.pptx';
|
|
133
|
+
|
|
134
|
+
const powerPointOutputOptions = new PDFNet.Convert.PowerPointOutputOptions();
|
|
135
|
+
|
|
136
|
+
// Convert only the first page
|
|
137
|
+
powerPointOutputOptions.setPages(1, 1);
|
|
138
|
+
|
|
139
|
+
await PDFNet.Convert.fileToPowerPoint(inputPath + 'paragraphs_and_tables.pdf', outputFile, powerPointOutputOptions);
|
|
140
|
+
|
|
141
|
+
console.log('Result saved in ' + outputFile);
|
|
142
|
+
} catch (err) {
|
|
143
|
+
console.log(err);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
//////////////////////////////////////////////////////////////////////////
|
|
147
|
+
|
|
148
|
+
console.log('Done.');
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) {
|
|
152
|
+
console.log('Error: ' + JSON.stringify(error));
|
|
153
|
+
}).then(function () { return PDFNet.shutdown(); });
|
|
154
|
+
};
|
|
155
|
+
exports.runPDF2OfficeTest();
|
|
156
|
+
})(exports);
|
|
157
|
+
// eslint-disable-next-line spaced-comment
|
|
158
|
+
//# sourceURL=PDF2OfficeTest.js
|
|
@@ -77,7 +77,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
77
77
|
console.log('PDFACompliance test completed.')
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
-
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) { console.log('Error: ' + JSON.stringify(error)); }).then(function () { PDFNet.shutdown(); });
|
|
80
|
+
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) { console.log('Error: ' + JSON.stringify(error)); }).then(function () { return PDFNet.shutdown(); });
|
|
81
81
|
};
|
|
82
82
|
exports.runPDFA();
|
|
83
83
|
})(exports);
|
|
@@ -77,7 +77,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
77
77
|
}
|
|
78
78
|
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error) {
|
|
79
79
|
console.log('Error: ' + JSON.stringify(error));
|
|
80
|
-
}).then(function(){ PDFNet.shutdown(); });
|
|
80
|
+
}).then(function(){ return PDFNet.shutdown(); });
|
|
81
81
|
};
|
|
82
82
|
exports.runPDFDocMemoryTest();
|
|
83
83
|
})(exports);
|
|
@@ -298,7 +298,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
298
298
|
}
|
|
299
299
|
};
|
|
300
300
|
|
|
301
|
-
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) { console.log('Error: ' + JSON.stringify(error)); }).then(function () { PDFNet.shutdown(); });
|
|
301
|
+
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) { console.log('Error: ' + JSON.stringify(error)); }).then(function () { return PDFNet.shutdown(); });
|
|
302
302
|
};
|
|
303
303
|
exports.runPDFDrawTest();
|
|
304
304
|
})(exports);
|
|
@@ -287,7 +287,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
287
287
|
console.log(err.stack);
|
|
288
288
|
}
|
|
289
289
|
};
|
|
290
|
-
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error){console.log('Error: ' + JSON.stringify(error));}).then(function(){PDFNet.shutdown();});
|
|
290
|
+
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error){console.log('Error: ' + JSON.stringify(error));}).then(function(){return PDFNet.shutdown();});
|
|
291
291
|
};
|
|
292
292
|
exports.runPDFLayersTest();
|
|
293
293
|
})(exports);
|
|
@@ -26,7 +26,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
26
26
|
fs.setDesc(desc);
|
|
27
27
|
|
|
28
28
|
const root = await doc.getRoot();
|
|
29
|
-
|
|
29
|
+
let collection = await root.findObj('Collection');
|
|
30
30
|
if (!collection) collection = await root.putDict('Collection');
|
|
31
31
|
|
|
32
32
|
// You could here manipulate any entry in the Collection dictionary.
|
|
@@ -104,7 +104,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
104
104
|
}
|
|
105
105
|
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error) {
|
|
106
106
|
console.log('Error: ' + JSON.stringify(error));
|
|
107
|
-
}).then(function(){ PDFNet.shutdown(); });
|
|
107
|
+
}).then(function(){ return PDFNet.shutdown(); });
|
|
108
108
|
};
|
|
109
109
|
exports.runPDFPackageTest();
|
|
110
110
|
})(exports);
|
|
@@ -182,7 +182,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
182
182
|
}
|
|
183
183
|
};
|
|
184
184
|
|
|
185
|
-
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) { console.log('Error: ' + JSON.stringify(error)); }).then(function () { PDFNet.shutdown(); });
|
|
185
|
+
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) { console.log('Error: ' + JSON.stringify(error)); }).then(function () { return PDFNet.shutdown(); });
|
|
186
186
|
};
|
|
187
187
|
exports.runPDFPageTest();
|
|
188
188
|
})(exports);
|
|
@@ -67,7 +67,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
67
67
|
console.log(err.stack);
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
|
-
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error){console.log('Error: ' + JSON.stringify(error));}).then(function(){PDFNet.shutdown();});
|
|
70
|
+
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error){console.log('Error: ' + JSON.stringify(error));}).then(function(){return PDFNet.shutdown();});
|
|
71
71
|
};
|
|
72
72
|
exports.runPDFRedactTest();
|
|
73
73
|
})(exports);
|
|
@@ -131,7 +131,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
131
131
|
}
|
|
132
132
|
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error) {
|
|
133
133
|
console.log('Error: ' + JSON.stringify(error));
|
|
134
|
-
}).then(function(){ PDFNet.shutdown(); });
|
|
134
|
+
}).then(function(){ return PDFNet.shutdown(); });
|
|
135
135
|
};
|
|
136
136
|
exports.runPageLabelsTest();
|
|
137
137
|
})(exports);
|
|
@@ -219,7 +219,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
219
219
|
}
|
|
220
220
|
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error) {
|
|
221
221
|
console.log('Error: ' + JSON.stringify(error));
|
|
222
|
-
}).then(function(){ PDFNet.shutdown(); });
|
|
222
|
+
}).then(function(){ return PDFNet.shutdown(); });
|
|
223
223
|
};
|
|
224
224
|
exports.runPatternTest();
|
|
225
225
|
})(exports);
|
|
@@ -33,7 +33,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
33
33
|
console.log(err);
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
|
-
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error){console.log('Error: ' + JSON.stringify(error));}).then(function(){PDFNet.shutdown();});
|
|
36
|
+
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error){console.log('Error: ' + JSON.stringify(error));}).then(function(){return PDFNet.shutdown();});
|
|
37
37
|
};
|
|
38
38
|
exports.runRectTest();
|
|
39
39
|
})(exports);
|
|
@@ -81,7 +81,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
81
81
|
console.log(err);
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
|
-
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error){console.log('Error: ' + JSON.stringify(error));}).then(function(){PDFNet.shutdown();});
|
|
84
|
+
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error){console.log('Error: ' + JSON.stringify(error));}).then(function(){return PDFNet.shutdown();});
|
|
85
85
|
};
|
|
86
86
|
exports.runSDFTest();
|
|
87
87
|
})(exports);
|
|
@@ -248,7 +248,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
248
248
|
console.log(err.stack);
|
|
249
249
|
}
|
|
250
250
|
};
|
|
251
|
-
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) { console.log('Error: ' + JSON.stringify(error)); }).then(function () { PDFNet.shutdown(); });
|
|
251
|
+
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) { console.log('Error: ' + JSON.stringify(error)); }).then(function () { return PDFNet.shutdown(); });
|
|
252
252
|
};
|
|
253
253
|
exports.runStamperTest();
|
|
254
254
|
})(exports);
|
|
@@ -279,7 +279,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
281
|
};
|
|
282
|
-
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) { console.log('Error: ' + JSON.stringify(error)); }).then(function () { PDFNet.shutdown(); });
|
|
282
|
+
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) { console.log('Error: ' + JSON.stringify(error)); }).then(function () { return PDFNet.shutdown(); });
|
|
283
283
|
};
|
|
284
284
|
exports.runTextExtractTest();
|
|
285
285
|
})(exports);
|
|
@@ -114,7 +114,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
114
114
|
console.log(err);
|
|
115
115
|
}
|
|
116
116
|
};
|
|
117
|
-
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error){console.log('Error: ' + JSON.stringify(error));}).then(function(){PDFNet.shutdown();});
|
|
117
|
+
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error){console.log('Error: ' + JSON.stringify(error));}).then(function(){return PDFNet.shutdown();});
|
|
118
118
|
};
|
|
119
119
|
exports.runTextSearchTest();
|
|
120
120
|
})(exports);
|
|
@@ -97,7 +97,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
97
97
|
}
|
|
98
98
|
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error) {
|
|
99
99
|
console.log('Error: ' + JSON.stringify(error));
|
|
100
|
-
}).then(function(){ PDFNet.shutdown(); });
|
|
100
|
+
}).then(function(){ return PDFNet.shutdown(); });
|
|
101
101
|
};
|
|
102
102
|
exports.runU3DTest();
|
|
103
103
|
})(exports);
|
|
@@ -93,7 +93,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
95
|
|
|
96
|
-
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) { console.log('Error: ' + JSON.stringify(error)); }).then(function () { PDFNet.shutdown(); });
|
|
96
|
+
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) { console.log('Error: ' + JSON.stringify(error)); }).then(function () { return PDFNet.shutdown(); });
|
|
97
97
|
};
|
|
98
98
|
exports.runUndoRedoTest();
|
|
99
99
|
})(exports);
|
|
@@ -166,7 +166,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
166
166
|
console.log(err);
|
|
167
167
|
}
|
|
168
168
|
};
|
|
169
|
-
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) { console.log('Error: ' + JSON.stringify(error)); }).then(function () { PDFNet.shutdown(); });
|
|
169
|
+
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) { console.log('Error: ' + JSON.stringify(error)); }).then(function () { return PDFNet.shutdown(); });
|
|
170
170
|
};
|
|
171
171
|
exports.runUnicodeWriteTest();
|
|
172
172
|
})(exports);
|
|
@@ -128,7 +128,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
128
128
|
|
|
129
129
|
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) {
|
|
130
130
|
console.log('Error: ' + JSON.stringify(error));
|
|
131
|
-
}).then(function () { PDFNet.shutdown(); });
|
|
131
|
+
}).then(function () { return PDFNet.shutdown(); });
|
|
132
132
|
};
|
|
133
133
|
exports.runWebViewerConvertTest();
|
|
134
134
|
})(exports);
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-2021 by PDFTron Systems Inc. All Rights Reserved.
|
|
3
|
-
// Consult legal.txt regarding legal and license information.
|
|
4
|
-
//---------------------------------------------------------------------------------------
|
|
5
|
-
|
|
6
|
-
//---------------------------------------------------------------------------------------
|
|
7
|
-
// The following sample illustrates how to use the PDF::Convert utility class to convert
|
|
8
|
-
// documents and files to Word.
|
|
9
|
-
//
|
|
10
|
-
// The Word module is an optional PDFNet Add-on that can be used to convert PDF
|
|
11
|
-
// documents into Word documents.
|
|
12
|
-
//
|
|
13
|
-
// The PDFTron SDK Word module can be downloaded from http://www.pdftron.com/
|
|
14
|
-
//
|
|
15
|
-
// Please contact us if you have any questions.
|
|
16
|
-
//---------------------------------------------------------------------------------------
|
|
17
|
-
|
|
18
|
-
const { PDFNet } = require('@pdftron/pdfnet-node');
|
|
19
|
-
const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
20
|
-
|
|
21
|
-
((exports) => {
|
|
22
|
-
'use strict';
|
|
23
|
-
|
|
24
|
-
exports.runPDF2WordTest = () => {
|
|
25
|
-
|
|
26
|
-
const main = async () => {
|
|
27
|
-
|
|
28
|
-
await PDFNet.addResourceSearchPath('../../lib/');
|
|
29
|
-
|
|
30
|
-
if (!await PDFNet.PDF2WordModule.isModuleAvailable())
|
|
31
|
-
{
|
|
32
|
-
console.log('\nUnable to run the sample: PDFTron SDK Word module not available.');
|
|
33
|
-
console.log('---------------------------------------------------------------');
|
|
34
|
-
console.log('The Word module is an optional add-on, available for download');
|
|
35
|
-
console.log('at http://www.pdftron.com/. If you have already downloaded this');
|
|
36
|
-
console.log('module, ensure that the SDK is able to find the required files');
|
|
37
|
-
console.log('using the PDFNet::AddResourceSearchPath() function.\n');
|
|
38
|
-
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const inputPath = '../TestFiles/';
|
|
43
|
-
const outputPath = '../TestFiles/Output/';
|
|
44
|
-
try {
|
|
45
|
-
// Convert PDF document to Word
|
|
46
|
-
console.log('Converting PDF to Word');
|
|
47
|
-
|
|
48
|
-
const outputFile = outputPath + 'paragraphs_and_tables.docx';
|
|
49
|
-
|
|
50
|
-
await PDFNet.Convert.fileToWord(inputPath + 'paragraphs_and_tables.pdf', outputFile);
|
|
51
|
-
|
|
52
|
-
console.log('Result saved in ' + outputFile);
|
|
53
|
-
} catch (err) {
|
|
54
|
-
console.log(err);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
try {
|
|
58
|
-
// Convert PDF document to Word with options
|
|
59
|
-
console.log('Converting PDF to Word with options');
|
|
60
|
-
|
|
61
|
-
const outputFile = outputPath + 'paragraphs_and_tables_first_page.docx';
|
|
62
|
-
|
|
63
|
-
const wordOutputOptions = new PDFNet.Convert.WordOutputOptions();
|
|
64
|
-
|
|
65
|
-
// Convert only the first page
|
|
66
|
-
wordOutputOptions.setPages(1, 1);
|
|
67
|
-
|
|
68
|
-
await PDFNet.Convert.fileToWord(inputPath + 'paragraphs_and_tables.pdf', outputFile, wordOutputOptions);
|
|
69
|
-
|
|
70
|
-
console.log('Result saved in ' + outputFile);
|
|
71
|
-
} catch (err) {
|
|
72
|
-
console.log(err);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
console.log('Done.');
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) {
|
|
79
|
-
console.log('Error: ' + JSON.stringify(error));
|
|
80
|
-
}).then(function () { PDFNet.shutdown(); });
|
|
81
|
-
};
|
|
82
|
-
exports.runPDF2WordTest();
|
|
83
|
-
})(exports);
|
|
84
|
-
// eslint-disable-next-line spaced-comment
|
|
85
|
-
//# sourceURL=PDF2WordTest.js
|