@pdftron/pdfnet-node-samples 9.5.0-3 → 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.
- package/{samples/AddImageTest → AddImageTest}/AddImageTest.js +2 -2
- package/{samples/AdvancedImagingTest → AdvancedImagingTest}/AdvancedImagingTest.js +6 -6
- package/{samples/AnnotationTest → AnnotationTest}/AnnotationTest.js +2 -2
- package/BarcodeTest/BarcodeTest.js +120 -0
- package/{samples/BookmarkTest → BookmarkTest}/BookmarkTest.js +2 -2
- package/{samples/CAD2PDFTest → CAD2PDFTest}/CAD2PDFTest.js +6 -6
- package/{samples/ContentReplacerTest → ContentReplacerTest}/ContentReplacerTest.js +2 -2
- package/ConvertPrintTest/ConvertPrintTest.js +153 -0
- package/{samples/ConvertTest → ConvertTest}/ConvertTest.js +13 -80
- package/DataExtractionTest/DataExtractionTest.js +311 -0
- package/{samples/DigitalSignaturesTest → DigitalSignaturesTest}/DigitalSignaturesTest.js +127 -13
- package/DocumentCreationTest/DocumentCreationTest.js +409 -0
- package/{samples/ElementBuilderTest → ElementBuilderTest}/ElementBuilderTest.js +2 -2
- package/{samples/ElementEditTest → ElementEditTest}/ElementEditTest.js +2 -2
- package/{samples/ElementReaderAdvTest → ElementReaderAdvTest}/ElementReaderAdvTest.js +2 -2
- package/{samples/ElementReaderTest → ElementReaderTest}/ElementReaderTest.js +2 -2
- package/{samples/EncTest → EncTest}/EncTest.js +2 -2
- package/{samples/FDFTest → FDFTest}/FDFTest.js +2 -2
- package/FindReplaceTest/FindReplaceTest.js +56 -0
- package/{samples/HTML2PDFTest → HTML2PDFTest}/HTML2PDFTest.js +35 -36
- package/{samples/HighlightsTest → HighlightsTest}/HighlightsTest.js +2 -2
- package/{samples/ImageExtractTest → ImageExtractTest}/ImageExtractTest.js +4 -4
- package/{samples/ImpositionTest → ImpositionTest}/ImpositionTest.js +2 -2
- package/{samples/InteractiveFormsTest → InteractiveFormsTest}/InteractiveFormsTest.js +2 -2
- package/{samples/JBIG2Test → JBIG2Test}/JBIG2Test.js +8 -8
- package/{samples/LicenseKey → LicenseKey}/LicenseKey.js +2 -2
- package/{samples/LogicalStructureTest → LogicalStructureTest}/LogicalStructureTest.js +2 -2
- package/{samples/OCRTest → OCRTest}/OCRTest.js +7 -6
- package/{samples/OfficeTemplateTest → OfficeTemplateTest}/OfficeTemplateTest.js +3 -3
- package/{samples/OfficeToPDFTest → OfficeToPDFTest}/OfficeToPDFTest.js +2 -2
- package/{samples/OptimizerTest → OptimizerTest}/OptimizerTest.js +2 -2
- package/{samples/PDF2HtmlTest → PDF2HtmlTest}/PDF2HtmlTest.js +7 -7
- package/{samples/PDF2OfficeTest → PDF2OfficeTest}/PDF2OfficeTest.js +7 -7
- package/{samples/PDFATest → PDFATest}/PDFATest.js +2 -2
- package/{samples/PDFDocMemoryTest → PDFDocMemoryTest}/PDFDocMemoryTest.js +2 -2
- package/{samples/PDFDrawTest → PDFDrawTest}/PDFDrawTest.js +2 -2
- package/{samples/PDFLayersTest → PDFLayersTest}/PDFLayersTest.js +2 -2
- package/{samples/PDFPackageTest → PDFPackageTest}/PDFPackageTest.js +2 -2
- package/{samples/PDFPageTest → PDFPageTest}/PDFPageTest.js +2 -2
- package/{samples/PDFRedactTest → PDFRedactTest}/PDFRedactTest.js +2 -2
- package/PDFUATest/PDFUATest.js +88 -0
- package/{samples/PageLabelsTest → PageLabelsTest}/PageLabelsTest.js +2 -2
- package/{samples/PatternTest → PatternTest}/PatternTest.js +2 -2
- package/{samples/RectTest → RectTest}/RectTest.js +2 -2
- package/{samples/SDFTest → SDFTest}/SDFTest.js +4 -5
- package/{samples/StamperTest → StamperTest}/StamperTest.js +2 -2
- package/TestFiles/BusinessCardTemplate.pdf +0 -0
- package/TestFiles/Email.pdf +0 -0
- package/TestFiles/Fishermen.docx +0 -0
- package/TestFiles/Font_licenses.txt +140 -0
- package/TestFiles/Invoice.pdf +0 -0
- package/TestFiles/License.txt +1 -0
- package/TestFiles/Misc-Fixed.pfa +1166 -0
- package/TestFiles/NotoSans_with_hindi.ttf +0 -0
- package/TestFiles/Output/empty +1 -0
- package/TestFiles/SHA-2 Root USERTrust RSA CA Sectigo timestamping.crt +34 -0
- package/TestFiles/SYH_Letter.docx +0 -0
- package/TestFiles/Scientific_Publication.pdf +0 -0
- package/TestFiles/TigerText.pdf +0 -0
- package/TestFiles/US061222892-a.pdf +0 -0
- package/TestFiles/apryse.bmp +0 -0
- package/TestFiles/apryse.cer +0 -0
- package/TestFiles/apryse.pfx +0 -0
- package/TestFiles/autotag_input.pdf +0 -0
- package/TestFiles/butterfly.png +0 -0
- package/TestFiles/credit card numbers.pdf +0 -0
- package/TestFiles/dice.jpg +0 -0
- package/TestFiles/dice.u3d +0 -0
- package/TestFiles/doc_to_sign.pdf +0 -0
- package/TestFiles/factsheet_Arabic.docx +0 -0
- package/TestFiles/financial.pdf +0 -0
- package/TestFiles/find-replace-test.pdf +0 -0
- package/TestFiles/find-replace-test_(en_to_fr).xlf +88 -0
- package/TestFiles/fish.pdf +0 -0
- package/TestFiles/font.ttf +0 -0
- package/TestFiles/form1.pdf +246 -0
- package/TestFiles/form1_annots.xfdf +34 -0
- package/TestFiles/form1_data.fdf +4 -0
- package/TestFiles/form1_data.xfdf +140 -0
- package/TestFiles/formfields-scanned-withfields.pdf +0 -0
- package/TestFiles/formfields-scanned.pdf +0 -0
- package/TestFiles/formfields.pdf +0 -0
- package/TestFiles/grayscale.tif +0 -0
- package/TestFiles/hindi_sample_utf16le.txt +0 -0
- package/TestFiles/imagemask.dat +32 -0
- package/TestFiles/logo_red.png +0 -0
- package/TestFiles/lorem_ipsum.pdf +0 -0
- package/TestFiles/multipage.tif +0 -0
- package/TestFiles/my_stream.txt +2310 -0
- package/TestFiles/newsletter.pdf +0 -0
- package/TestFiles/newsletter.xod +0 -0
- package/TestFiles/numbered.pdf +0 -0
- package/TestFiles/op_blend_test.pdf +1497 -1
- package/TestFiles/palm.jp2 +0 -0
- package/TestFiles/paragraphs_and_tables.pdf +0 -0
- package/TestFiles/pdfnet.gif +0 -0
- package/TestFiles/pdftron_smart_substitution.plugin +0 -0
- package/TestFiles/peppers.jpg +0 -0
- package/TestFiles/signature.jpg +0 -0
- package/TestFiles/simple-emf.emf +0 -0
- package/TestFiles/simple-excel_2007.xlsx +0 -0
- package/TestFiles/simple-outlook.msg +0 -0
- package/TestFiles/simple-powerpoint_2007.pptx +0 -0
- package/TestFiles/simple-publisher.pub +0 -0
- package/TestFiles/simple-rtf.rtf +224 -0
- package/TestFiles/simple-text.txt +61 -0
- package/TestFiles/simple-visio.vsd +0 -0
- package/TestFiles/simple-webpage.html +731 -0
- package/TestFiles/simple-webpage.mht +6972 -0
- package/TestFiles/simple-webpage_files/colorschememapping.xml +2 -0
- package/TestFiles/simple-webpage_files/filelist.xml +14 -0
- package/TestFiles/simple-webpage_files/image001.gif +0 -0
- package/TestFiles/simple-webpage_files/image002.png +0 -0
- package/TestFiles/simple-webpage_files/image003.jpg +0 -0
- package/TestFiles/simple-webpage_files/image004.emz +0 -0
- package/TestFiles/simple-webpage_files/image005.gif +0 -0
- package/TestFiles/simple-webpage_files/image006.png +0 -0
- package/TestFiles/simple-webpage_files/image007.gif +0 -0
- package/TestFiles/simple-webpage_files/oledata.mso +0 -0
- package/TestFiles/simple-webpage_files/themedata.thmx +0 -0
- package/TestFiles/simple-word_2007.docx +0 -0
- package/TestFiles/simple-xps.xps +0 -0
- package/TestFiles/table.pdf +0 -0
- package/TestFiles/tagged.pdf +0 -0
- package/TestFiles/the_rime_of_the_ancient_mariner.docx +0 -0
- package/TestFiles/tiger.pdf +0 -0
- package/TestFiles/tiger.svg +378 -0
- package/TestFiles/waiver.pdf +0 -0
- package/TestFiles/waiver_withApprovalField.pdf +0 -0
- package/TestFiles/waiver_withApprovalField_certified.pdf +421 -1
- package/TestFiles/waiver_withApprovalField_certified_approved.pdf +465 -1
- package/{samples/TextExtractTest → TextExtractTest}/TextExtractTest.js +2 -2
- package/{samples/TextSearchTest → TextSearchTest}/TextSearchTest.js +3 -3
- package/TransPDFTest/TransPDFTest.js +68 -0
- package/{samples/U3DTest → U3DTest}/U3DTest.js +2 -2
- package/{samples/UndoRedoTest → UndoRedoTest}/UndoRedoTest.js +2 -2
- package/{samples/UnicodeWriteTest → UnicodeWriteTest}/UnicodeWriteTest.js +2 -2
- package/{samples/WebViewerConvertTest → WebViewerConvertTest}/WebViewerConvertTest.js +3 -3
- package/legal.txt +632 -0
- package/license.pdf +0 -0
- package/package.json +9 -7
- package/readme.md +32 -7
- package/{samples/runall.bat → runall.bat} +12 -12
- package/scripts/install.js +68 -0
- package/samples/DataExtractionTest/DataExtractionTest.js +0 -180
- /package/{samples/runall.sh → runall.sh} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-
|
|
2
|
+
// Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved.
|
|
3
3
|
// Consult legal.txt regarding legal and license information.
|
|
4
4
|
//---------------------------------------------------------------------------------------
|
|
5
5
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// 'pdftron.PDF.HTML2PDF' is an optional PDFNet Add-On utility class that can be
|
|
11
11
|
// used to convert HTML web pages into PDF documents by using an external module (html2pdf).
|
|
12
12
|
//
|
|
13
|
-
// html2pdf modules can be downloaded from
|
|
13
|
+
// html2pdf modules can be downloaded from https://docs.apryse.com/core/guides/info/modules#html2pdf-module
|
|
14
14
|
//
|
|
15
15
|
// Users can convert HTML pages to PDF using the following operations:
|
|
16
16
|
// - Simple one line static method to convert a single web page to PDF.
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
// - Optionally add table of contents, including setting the depth and appearance.
|
|
21
21
|
//---------------------------------------------------------------------------------------
|
|
22
22
|
|
|
23
|
-
const { PDFNet } = require('
|
|
23
|
+
const { PDFNet } = require('@pdftron/pdfnet-node');
|
|
24
24
|
const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
25
25
|
|
|
26
26
|
((exports) => {
|
|
@@ -29,20 +29,21 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
29
29
|
exports.runHTML2PDFTest = () => {
|
|
30
30
|
const main = async () => {
|
|
31
31
|
const outputPath = '../TestFiles/Output/html2pdf_example';
|
|
32
|
-
const host = 'https://
|
|
32
|
+
const host = 'https://docs.apryse.com';
|
|
33
33
|
const page0 = '/';
|
|
34
|
-
const page1 = '/
|
|
35
|
-
const page2 = '/
|
|
34
|
+
const page1 = '/all-products/';
|
|
35
|
+
const page2 = '/documentation/web/faq';
|
|
36
|
+
|
|
36
37
|
// For HTML2PDF we need to locate the html2pdf module. If placed with the
|
|
37
38
|
// PDFNet library, or in the current working directory, it will be loaded
|
|
38
39
|
// automatically. Otherwise, it must be set manually using HTML2PDF.setModulePath.
|
|
39
|
-
await PDFNet.HTML2PDF.setModulePath('
|
|
40
|
+
await PDFNet.HTML2PDF.setModulePath('../../lib/');
|
|
40
41
|
|
|
41
42
|
if(!(await PDFNet.HTML2PDF.isModuleAvailable())) {
|
|
42
|
-
console.log('Unable to run HTML2PDFTest:
|
|
43
|
+
console.log('Unable to run HTML2PDFTest: Apryse SDK HTML2PDF module not available.');
|
|
43
44
|
console.log('---------------------------------------------------------------');
|
|
44
45
|
console.log('The HTML2PDF module is an optional add-on, available for download');
|
|
45
|
-
console.log('at https://www.
|
|
46
|
+
console.log('at https://www.apryse.com/. If you have already downloaded this');
|
|
46
47
|
console.log('module, ensure that the SDK is able to find the required files');
|
|
47
48
|
console.log('using the HTML2PDF.setModulePath() function.');
|
|
48
49
|
|
|
@@ -58,11 +59,8 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
58
59
|
|
|
59
60
|
html2pdf.insertFromUrl(host.concat(page0));
|
|
60
61
|
// now convert a web page, sending generated PDF pages to doc
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
} else {
|
|
64
|
-
console.log('Conversion failed.');
|
|
65
|
-
}
|
|
62
|
+
await html2pdf.convert(doc);
|
|
63
|
+
doc.save(outputPath.concat('_01.pdf'), PDFNet.SDFDoc.SaveOptions.e_linearized);
|
|
66
64
|
} catch (err) {
|
|
67
65
|
console.log(err);
|
|
68
66
|
}
|
|
@@ -84,12 +82,8 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
84
82
|
html2pdf.insertFromUrl(host.concat(page0));
|
|
85
83
|
|
|
86
84
|
// convert the web page, appending generated PDF pages to doc
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
} else {
|
|
90
|
-
console.log('Conversion failed. HTTP Code: ' + await html2pdf.getHttpErrorCode());
|
|
91
|
-
console.log(await html2pdf.getLog());
|
|
92
|
-
}
|
|
85
|
+
await html2pdf.convert(doc);
|
|
86
|
+
doc.save(outputPath.concat('_02.pdf'), PDFNet.SDFDoc.SaveOptions.e_linearized);
|
|
93
87
|
} catch (err) {
|
|
94
88
|
console.log(err);
|
|
95
89
|
}
|
|
@@ -111,11 +105,11 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
111
105
|
const settings = await PDFNet.HTML2PDF.WebPageSettings.create();
|
|
112
106
|
await settings.setZoom(0.5);
|
|
113
107
|
converter.insertFromUrl2(host.concat(page0), settings);
|
|
114
|
-
|
|
108
|
+
await converter.convert(doc);
|
|
115
109
|
|
|
116
110
|
// convert page 1 with the same settings, appending generated PDF pages to doc
|
|
117
111
|
converter.insertFromUrl2(host.concat(page1), settings);
|
|
118
|
-
|
|
112
|
+
await converter.convert(doc);
|
|
119
113
|
|
|
120
114
|
// convert page 2 with different settings, appending generated PDF pages to doc
|
|
121
115
|
const another_converter = await PDFNet.HTML2PDF.create();
|
|
@@ -123,14 +117,9 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
123
117
|
const another_settings = await PDFNet.HTML2PDF.WebPageSettings.create();
|
|
124
118
|
another_settings.setPrintBackground(false);
|
|
125
119
|
another_converter.insertFromUrl2(host.concat(page2), another_settings);
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
doc.save(outputPath.concat('_03.pdf'), PDFNet.SDFDoc.SaveOptions.e_linearized);
|
|
130
|
-
} else {
|
|
131
|
-
console.log('Conversion failed. HTTP Code: ' + await html2pdf.getHttpErrorCode());
|
|
132
|
-
console.log(await html2pdf.getLog());
|
|
133
|
-
}
|
|
120
|
+
await another_converter.convert(doc);
|
|
121
|
+
|
|
122
|
+
doc.save(outputPath.concat('_03.pdf'), PDFNet.SDFDoc.SaveOptions.e_linearized);
|
|
134
123
|
} catch (err) {
|
|
135
124
|
console.log(err);
|
|
136
125
|
}
|
|
@@ -144,12 +133,22 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
144
133
|
const html = '<html><body><h1>Heading</h1><p>Paragraph.</p></body></html>';
|
|
145
134
|
|
|
146
135
|
html2pdf.insertFromHtmlString(html);
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
136
|
+
await html2pdf.convert(doc);
|
|
137
|
+
doc.save(outputPath.concat('_04.pdf'), PDFNet.SDFDoc.SaveOptions.e_linearized);
|
|
138
|
+
} catch (err) {
|
|
139
|
+
console.log(err);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
//--------------------------------------------------------------------------------
|
|
143
|
+
// Example 5) Set the location of the log file to be used during conversion.
|
|
144
|
+
|
|
145
|
+
try {
|
|
146
|
+
const html2pdf = await PDFNet.HTML2PDF.create();
|
|
147
|
+
const doc = await PDFNet.PDFDoc.create();
|
|
148
|
+
html2pdf.setLogFilePath('../TestFiles/Output/html2pdf.log');
|
|
149
|
+
html2pdf.insertFromUrl(host.concat(page0));
|
|
150
|
+
await html2pdf.convert(doc);
|
|
151
|
+
doc.save(outputPath.concat('_05.pdf'), PDFNet.SDFDoc.SaveOptions.e_linearized);
|
|
153
152
|
} catch (err) {
|
|
154
153
|
console.log(err);
|
|
155
154
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-
|
|
2
|
+
// Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved.
|
|
3
3
|
// Consult legal.txt regarding legal and license information.
|
|
4
4
|
//---------------------------------------------------------------------------------------
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
const { PDFNet } = require('
|
|
7
|
+
const { PDFNet } = require('@pdftron/pdfnet-node');
|
|
8
8
|
const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
9
9
|
|
|
10
10
|
// This sample illustrates the basic text highlight capabilities of PDFNet.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-
|
|
2
|
+
// Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved.
|
|
3
3
|
// Consult legal.txt regarding legal and license information.
|
|
4
4
|
//---------------------------------------------------------------------------------------
|
|
5
5
|
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
// sample project).
|
|
14
14
|
//-----------------------------------------------------------------------------------
|
|
15
15
|
|
|
16
|
-
const { PDFNet } = require('
|
|
16
|
+
const { PDFNet } = require('@pdftron/pdfnet-node');
|
|
17
17
|
const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
18
18
|
|
|
19
19
|
((exports) => {
|
|
@@ -98,11 +98,11 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
98
98
|
if (obj && !(await obj.isFree()) && await obj.isStream()) {
|
|
99
99
|
// Process only images
|
|
100
100
|
var itr = await obj.find('Type');
|
|
101
|
-
if (!(await itr.
|
|
101
|
+
if (!(await itr.hasCurrent()) || await (await itr.value()).getName() !== 'XObject')
|
|
102
102
|
continue;
|
|
103
103
|
|
|
104
104
|
itr = await obj.find('Subtype');
|
|
105
|
-
if (!(await itr.
|
|
105
|
+
if (!(await itr.hasCurrent()) || await (await itr.value()).getName() !== 'Image')
|
|
106
106
|
continue;
|
|
107
107
|
const image = await PDFNet.Image.createFromObj(obj);
|
|
108
108
|
console.log('--> Image: ' + ++image_counter);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-
|
|
2
|
+
// Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved.
|
|
3
3
|
// Consult legal.txt regarding legal and license information.
|
|
4
4
|
//---------------------------------------------------------------------------------------
|
|
5
5
|
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
// when the hard copy pages are compiled and folded correctly.
|
|
13
13
|
//-----------------------------------------------------------------------------------
|
|
14
14
|
|
|
15
|
-
const { PDFNet } = require('
|
|
15
|
+
const { PDFNet } = require('@pdftron/pdfnet-node');
|
|
16
16
|
const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
17
17
|
|
|
18
18
|
((exports) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-
|
|
2
|
+
// Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved.
|
|
3
3
|
// Consult legal.txt regarding legal and license information.
|
|
4
4
|
//---------------------------------------------------------------------------------------
|
|
5
5
|
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// This sample illustrates basic PDFNet capabilities related to interactive
|
|
8
8
|
// forms (also known as AcroForms).
|
|
9
9
|
//---------------------------------------------------------------------------------------
|
|
10
|
-
const { PDFNet } = require('
|
|
10
|
+
const { PDFNet } = require('@pdftron/pdfnet-node');
|
|
11
11
|
const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
12
12
|
|
|
13
13
|
((exports) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-
|
|
2
|
+
// Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved.
|
|
3
3
|
// Consult legal.txt regarding legal and license information.
|
|
4
4
|
//---------------------------------------------------------------------------------------
|
|
5
5
|
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
// to be a generic PDF optimization tool.
|
|
10
10
|
//
|
|
11
11
|
// You can download the entire document using the following link:
|
|
12
|
-
//
|
|
12
|
+
// https://downloads.apryse.com/files/US061222892.pdf
|
|
13
13
|
//
|
|
14
14
|
|
|
15
|
-
const { PDFNet } = require('
|
|
15
|
+
const { PDFNet } = require('@pdftron/pdfnet-node');
|
|
16
16
|
const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
17
17
|
|
|
18
18
|
((exports) => {
|
|
@@ -31,7 +31,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
31
31
|
if (obj && !(await obj.isFree()) && await obj.isStream()) {
|
|
32
32
|
// Process only images
|
|
33
33
|
let itr = await obj.find('Subtype');
|
|
34
|
-
if (!(await itr.
|
|
34
|
+
if (!(await itr.hasCurrent()) || await (await itr.value()).getName() !== 'Image')
|
|
35
35
|
continue;
|
|
36
36
|
const input_image = await PDFNet.Image.createFromObj(obj);
|
|
37
37
|
// Process only gray-scale images
|
|
@@ -42,7 +42,7 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
42
42
|
|
|
43
43
|
// Skip images that are already compressed using JBIG2
|
|
44
44
|
itr = await obj.find('Filter');
|
|
45
|
-
if (await itr.
|
|
45
|
+
if (await itr.hasCurrent()) {
|
|
46
46
|
const value = await itr.value();
|
|
47
47
|
if (await value.isName() && await value.getName() === 'JBIG2Decode') continue;
|
|
48
48
|
}
|
|
@@ -61,13 +61,13 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
61
61
|
|
|
62
62
|
const new_img_obj = await new_image.getSDFObj();
|
|
63
63
|
itr = await obj.find('Decode');
|
|
64
|
-
if (await itr.
|
|
64
|
+
if (await itr.hasCurrent())
|
|
65
65
|
new_img_obj.put('Decode', await itr.value());
|
|
66
66
|
itr = await obj.find('ImageMask');
|
|
67
|
-
if (await itr.
|
|
67
|
+
if (await itr.hasCurrent())
|
|
68
68
|
new_img_obj.put('ImageMask', await itr.value());
|
|
69
69
|
itr = await obj.find('Mask');
|
|
70
|
-
if (await itr.
|
|
70
|
+
if (await itr.hasCurrent())
|
|
71
71
|
new_img_obj.put('Mask', await itr.value());
|
|
72
72
|
|
|
73
73
|
await cos_doc.swap(i, await new_img_obj.getObjNum());
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-
|
|
2
|
+
// Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved.
|
|
3
3
|
// Consult legal.txt regarding legal and license information.
|
|
4
4
|
//---------------------------------------------------------------------------------------
|
|
5
5
|
|
|
6
|
-
//"Enter your key here. If you don't have it, please go to https://www.
|
|
6
|
+
//"Enter your key here. If you don't have it, please go to https://www.apryse.com/pws/get-key to obtain a demo license or https://www.apryse.com/form/contact-sales to obtain a production key.
|
|
7
7
|
const LicenseKey = 'YOUR_PDFTRON_LICENSE_KEY';
|
|
8
8
|
if(LicenseKey == 'YOUR_PDFTRON_LICENSE_KEY'){
|
|
9
9
|
throw ('Please enter your license key by replacing \'YOUR_PDFTRON_LICENSE_KEY\' that is assigned to the LicenseKey variable in Samples/LicenseKey/LicenseKey.js. If you do not have a license key, 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.');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-
|
|
2
|
+
// Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved.
|
|
3
3
|
// Consult legal.txt regarding legal and license information.
|
|
4
4
|
//---------------------------------------------------------------------------------------
|
|
5
5
|
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
//---------------------------------------------------------------------------------------
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
const { PDFNet } = require('
|
|
19
|
+
const { PDFNet } = require('@pdftron/pdfnet-node');
|
|
20
20
|
const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
21
21
|
|
|
22
22
|
((exports) => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-
|
|
2
|
+
// Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved.
|
|
3
3
|
// Consult legal.txt regarding legal and license information.
|
|
4
4
|
//---------------------------------------------------------------------------------------
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
const { PDFNet } = require('
|
|
7
|
+
const { PDFNet } = require('@pdftron/pdfnet-node');
|
|
8
8
|
const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
9
9
|
|
|
10
10
|
((exports) => {
|
|
@@ -17,14 +17,14 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
17
17
|
const main = async () => {
|
|
18
18
|
try {
|
|
19
19
|
|
|
20
|
-
PDFNet.addResourceSearchPath('
|
|
20
|
+
PDFNet.addResourceSearchPath('../../lib/');
|
|
21
21
|
|
|
22
22
|
const useIRIS = await PDFNet.OCRModule.isIRISModuleAvailable();
|
|
23
23
|
if (!(await PDFNet.OCRModule.isModuleAvailable())) {
|
|
24
|
-
console.log('\nUnable to run OCRTest:
|
|
24
|
+
console.log('\nUnable to run OCRTest: Apryse SDK OCR module not available.');
|
|
25
25
|
console.log('---------------------------------------------------------------');
|
|
26
26
|
console.log('The OCR module is an optional add-on, available for download');
|
|
27
|
-
console.log('at http://www.
|
|
27
|
+
console.log('at http://www.apryse.com/. If you have already downloaded this');
|
|
28
28
|
console.log('module, ensure that the SDK is able to find the required files');
|
|
29
29
|
console.log('using the PDFNet.addResourceSearchPath() function.\n');
|
|
30
30
|
|
|
@@ -69,8 +69,9 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
69
69
|
// B) Setup options with multiple target languages, English will always be considered as secondary language
|
|
70
70
|
const opts = new PDFNet.OCRModule.OCROptions();
|
|
71
71
|
if(useIRIS) opts.setOCREngine('iris');
|
|
72
|
-
opts.addLang('rus');
|
|
73
72
|
opts.addLang('deu');
|
|
73
|
+
opts.addLang('fra');
|
|
74
|
+
opts.addLang('eng');
|
|
74
75
|
|
|
75
76
|
// C) Run OCR on the .jpg with options
|
|
76
77
|
await PDFNet.OCRModule.imageToPDF(doc, input_path + 'multi_lang.jpg', opts);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-
|
|
2
|
+
// Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved.
|
|
3
3
|
// Consult legal.txt regarding legal and license information.
|
|
4
4
|
//---------------------------------------------------------------------------------------
|
|
5
5
|
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// with content supplied via json
|
|
10
10
|
//
|
|
11
11
|
// For a detailed specification of the template format and supported features,
|
|
12
|
-
// see: https://
|
|
12
|
+
// see: https://docs.apryse.com/documentation/core/guides/generate-via-template/data-model/
|
|
13
13
|
//
|
|
14
14
|
// This conversion is performed entirely within the PDFNet and has *no*
|
|
15
15
|
// external or system dependencies -- Conversion results will be
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
// Please contact us if you have any questions.
|
|
19
19
|
//------------------------------------------------------------------------------
|
|
20
20
|
|
|
21
|
-
const { PDFNet } = require('
|
|
21
|
+
const { PDFNet } = require('@pdftron/pdfnet-node');
|
|
22
22
|
const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
23
23
|
|
|
24
24
|
((exports) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-
|
|
2
|
+
// Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved.
|
|
3
3
|
// Consult legal.txt regarding legal and license information.
|
|
4
4
|
//---------------------------------------------------------------------------------------
|
|
5
5
|
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// Please contact us if you have any questions.
|
|
15
15
|
//------------------------------------------------------------------------------
|
|
16
16
|
|
|
17
|
-
const { PDFNet } = require('
|
|
17
|
+
const { PDFNet } = require('@pdftron/pdfnet-node');
|
|
18
18
|
const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
19
19
|
|
|
20
20
|
((exports) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-
|
|
2
|
+
// Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved.
|
|
3
3
|
// Consult legal.txt regarding legal and license information.
|
|
4
4
|
//---------------------------------------------------------------------------------------
|
|
5
5
|
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
// very simple representation (e.g. vector text on top of a background image).
|
|
34
34
|
//---------------------------------------------------------------------------------------
|
|
35
35
|
|
|
36
|
-
const { PDFNet } = require('
|
|
36
|
+
const { PDFNet } = require('@pdftron/pdfnet-node');
|
|
37
37
|
const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
38
38
|
|
|
39
39
|
((exports) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-
|
|
2
|
+
// Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved.
|
|
3
3
|
// Consult legal.txt regarding legal and license information.
|
|
4
4
|
//---------------------------------------------------------------------------------------
|
|
5
5
|
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
// 2. The optional Structured Output add-on module is used to convert PDF documents to
|
|
14
14
|
// HTML documents with text flowing across the browser window.
|
|
15
15
|
//
|
|
16
|
-
// The
|
|
17
|
-
// https://
|
|
16
|
+
// The Apryse SDK Structured Output module can be downloaded from
|
|
17
|
+
// https://docs.apryse.com/documentation/core/info/modules/
|
|
18
18
|
//
|
|
19
19
|
// Please contact us if you have any questions.
|
|
20
20
|
//---------------------------------------------------------------------------------------
|
|
21
21
|
|
|
22
|
-
const { PDFNet } = require('
|
|
22
|
+
const { PDFNet } = require('@pdftron/pdfnet-node');
|
|
23
23
|
const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
24
24
|
|
|
25
25
|
((exports) => {
|
|
@@ -50,13 +50,13 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
50
50
|
|
|
51
51
|
//////////////////////////////////////////////////////////////////////////
|
|
52
52
|
|
|
53
|
-
await PDFNet.addResourceSearchPath('
|
|
53
|
+
await PDFNet.addResourceSearchPath('../../lib/');
|
|
54
54
|
|
|
55
55
|
if (!await PDFNet.StructuredOutputModule.isModuleAvailable()) {
|
|
56
|
-
console.log('\nUnable to run part of the sample:
|
|
56
|
+
console.log('\nUnable to run part of the sample: Apryse SDK Structured Output module not available.');
|
|
57
57
|
console.log('---------------------------------------------------------------');
|
|
58
58
|
console.log('The Structured Output module is an optional add-on, available for download');
|
|
59
|
-
console.log('at https://
|
|
59
|
+
console.log('at https://docs.apryse.com/documentation/core/info/modules/. If you have already');
|
|
60
60
|
console.log('downloaded this module, ensure that the SDK is able to find the required files');
|
|
61
61
|
console.log('using the PDFNet::AddResourceSearchPath() function.\n');
|
|
62
62
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-
|
|
2
|
+
// Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved.
|
|
3
3
|
// Consult legal.txt regarding legal and license information.
|
|
4
4
|
//---------------------------------------------------------------------------------------
|
|
5
5
|
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
// The Structured Output module is an optional PDFNet Add-on that can be used to convert PDF
|
|
11
11
|
// and other documents into Word, Excel, PowerPoint and HTML format.
|
|
12
12
|
//
|
|
13
|
-
// The
|
|
14
|
-
// https://
|
|
13
|
+
// The Apryse SDK Structured Output module can be downloaded from
|
|
14
|
+
// https://docs.apryse.com/documentation/core/info/modules/
|
|
15
15
|
//
|
|
16
16
|
// Please contact us if you have any questions.
|
|
17
17
|
//---------------------------------------------------------------------------------------
|
|
18
18
|
|
|
19
|
-
const { PDFNet } = require('
|
|
19
|
+
const { PDFNet } = require('@pdftron/pdfnet-node');
|
|
20
20
|
const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
21
21
|
|
|
22
22
|
((exports) => {
|
|
@@ -31,13 +31,13 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
31
31
|
|
|
32
32
|
//////////////////////////////////////////////////////////////////////////
|
|
33
33
|
|
|
34
|
-
await PDFNet.addResourceSearchPath('
|
|
34
|
+
await PDFNet.addResourceSearchPath('../../lib/');
|
|
35
35
|
|
|
36
36
|
if (!await PDFNet.StructuredOutputModule.isModuleAvailable()) {
|
|
37
|
-
console.log('\nUnable to run the sample:
|
|
37
|
+
console.log('\nUnable to run the sample: Apryse SDK Structured Output module not available.');
|
|
38
38
|
console.log('---------------------------------------------------------------');
|
|
39
39
|
console.log('The Structured Output module is an optional add-on, available for download');
|
|
40
|
-
console.log('at https://
|
|
40
|
+
console.log('at https://docs.apryse.com/documentation/core/info/modules/. If you have already');
|
|
41
41
|
console.log('downloaded this module, ensure that the SDK is able to find the required files');
|
|
42
42
|
console.log('using the PDFNet::AddResourceSearchPath() function.\n');
|
|
43
43
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-
|
|
2
|
+
// Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved.
|
|
3
3
|
// Consult legal.txt regarding legal and license information.
|
|
4
4
|
//---------------------------------------------------------------------------------------
|
|
5
5
|
|
|
6
|
-
const { PDFNet } = require('
|
|
6
|
+
const { PDFNet } = require('@pdftron/pdfnet-node');
|
|
7
7
|
const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
8
8
|
|
|
9
9
|
((exports) => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-
|
|
2
|
+
// Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved.
|
|
3
3
|
// Consult legal.txt regarding legal and license information.
|
|
4
4
|
//---------------------------------------------------------------------------------------
|
|
5
5
|
|
|
6
6
|
const fs = require('fs');
|
|
7
|
-
const { PDFNet } = require('
|
|
7
|
+
const { PDFNet } = require('@pdftron/pdfnet-node');
|
|
8
8
|
const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
9
9
|
|
|
10
10
|
((exports) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-
|
|
2
|
+
// Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved.
|
|
3
3
|
// Consult legal.txt regarding legal and license information.
|
|
4
4
|
//---------------------------------------------------------------------------------------
|
|
5
5
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
//---------------------------------------------------------------------------------------
|
|
11
11
|
|
|
12
12
|
const fs = require('fs');
|
|
13
|
-
const { PDFNet } = require('
|
|
13
|
+
const { PDFNet } = require('@pdftron/pdfnet-node');
|
|
14
14
|
const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
15
15
|
|
|
16
16
|
((exports) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-
|
|
2
|
+
// Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved.
|
|
3
3
|
// Consult legal.txt regarding legal and license information.
|
|
4
4
|
//---------------------------------------------------------------------------------------
|
|
5
5
|
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
// to process.
|
|
29
29
|
//-----------------------------------------------------------------------------------
|
|
30
30
|
|
|
31
|
-
const { PDFNet } = require('
|
|
31
|
+
const { PDFNet } = require('@pdftron/pdfnet-node');
|
|
32
32
|
const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
33
33
|
|
|
34
34
|
((exports) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-
|
|
2
|
+
// Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved.
|
|
3
3
|
// Consult legal.txt regarding legal and license information.
|
|
4
4
|
//---------------------------------------------------------------------------------------
|
|
5
5
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
/// (a.k.a. PDF Packages) using PDFNet SDK.
|
|
9
9
|
//-----------------------------------------------------------------------------------
|
|
10
10
|
|
|
11
|
-
const { PDFNet } = require('
|
|
11
|
+
const { PDFNet } = require('@pdftron/pdfnet-node');
|
|
12
12
|
const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
13
13
|
|
|
14
14
|
((exports) => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-
|
|
2
|
+
// Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved.
|
|
3
3
|
// Consult legal.txt regarding legal and license information.
|
|
4
4
|
//---------------------------------------------------------------------------------------
|
|
5
5
|
|
|
6
|
-
const { PDFNet } = require('
|
|
6
|
+
const { PDFNet } = require('@pdftron/pdfnet-node');
|
|
7
7
|
const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
8
8
|
|
|
9
9
|
((exports) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-
|
|
2
|
+
// Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved.
|
|
3
3
|
// Consult legal.txt regarding legal and license information.
|
|
4
4
|
//---------------------------------------------------------------------------------------
|
|
5
5
|
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
// document, including XML Forms Architecture (XFA) content and Extensible Metadata
|
|
33
33
|
// Platform (XMP) content.
|
|
34
34
|
|
|
35
|
-
const { PDFNet } = require('
|
|
35
|
+
const { PDFNet } = require('@pdftron/pdfnet-node');
|
|
36
36
|
const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
37
37
|
|
|
38
38
|
((exports) => {
|