@pdftron/pdfnet-node-samples 9.4.2 → 9.5.0
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 +12 -12
- package/samples/AddImageTest/AddImageTest.js +1 -1
- package/samples/AddImageTest/NODEJS/AddImageTest.js +116 -0
- package/samples/AddImageTest/NODEJS/RunTest.sh +2 -0
- package/samples/AdvancedImagingTest/AdvancedImagingTest.js +1 -1
- package/samples/AdvancedImagingTest/NODEJS/AdvancedImagingTest.js +78 -0
- package/samples/AdvancedImagingTest/NODEJS/RunTest.sh +2 -0
- package/samples/AnnotationTest/AnnotationTest.js +1 -1
- package/samples/AnnotationTest/NODEJS/AnnotationTest.js +642 -0
- package/samples/AnnotationTest/NODEJS/RunTest.sh +2 -0
- package/samples/BookmarkTest/BookmarkTest.js +1 -1
- package/samples/BookmarkTest/NODEJS/BookmarkTest.js +220 -0
- package/samples/BookmarkTest/NODEJS/RunTest.sh +2 -0
- package/samples/CAD2PDFTest/CAD2PDFTest.js +79 -79
- package/samples/CAD2PDFTest/NODEJS/CAD2PDFTest.js +80 -0
- package/samples/CAD2PDFTest/NODEJS/RunTest.sh +2 -0
- package/samples/ContentReplacerTest/ContentReplacerTest.js +1 -1
- package/samples/ContentReplacerTest/NODEJS/ContentReplacerTest.js +75 -0
- package/samples/ContentReplacerTest/NODEJS/RunTest.sh +2 -0
- package/samples/ConvertTest/ConvertTest.js +270 -256
- package/samples/ConvertTest/NODEJS/ConvertTest.js +270 -0
- package/samples/ConvertTest/NODEJS/RunTest.sh +2 -0
- package/samples/DataExtractionTest/DataExtractionTest.js +180 -0
- package/samples/DataExtractionTest/NODEJS/DataExtractionTest.js +180 -0
- package/samples/DataExtractionTest/NODEJS/RunTest.sh +2 -0
- package/samples/DigitalSignaturesTest/DigitalSignaturesTest.js +526 -526
- package/samples/DigitalSignaturesTest/NODEJS/DigitalSignaturesTest.js +527 -0
- package/samples/DigitalSignaturesTest/NODEJS/RunTest.sh +2 -0
- package/samples/ElementBuilderTest/ElementBuilderTest.js +1 -1
- package/samples/ElementBuilderTest/NODEJS/ElementBuilderTest.js +514 -0
- package/samples/ElementBuilderTest/NODEJS/RunTest.sh +2 -0
- package/samples/ElementEditTest/ElementEditTest.js +1 -1
- package/samples/ElementEditTest/NODEJS/ElementEditTest.js +111 -0
- package/samples/ElementEditTest/NODEJS/RunTest.sh +2 -0
- package/samples/ElementReaderAdvTest/ElementReaderAdvTest.js +1 -1
- package/samples/ElementReaderAdvTest/NODEJS/ElementReaderAdvTest.js +305 -0
- package/samples/ElementReaderAdvTest/NODEJS/RunTest.sh +2 -0
- package/samples/ElementReaderTest/ElementReaderTest.js +1 -1
- package/samples/ElementReaderTest/NODEJS/ElementReaderTest.js +77 -0
- package/samples/ElementReaderTest/NODEJS/RunTest.sh +2 -0
- package/samples/EncTest/EncTest.js +1 -1
- package/samples/EncTest/NODEJS/EncTest.js +176 -0
- package/samples/EncTest/NODEJS/RunTest.sh +2 -0
- package/samples/FDFTest/FDFTest.js +218 -218
- package/samples/FDFTest/NODEJS/FDFTest.js +219 -0
- package/samples/FDFTest/NODEJS/RunTest.sh +2 -0
- package/samples/HTML2PDFTest/HTML2PDFTest.js +165 -165
- package/samples/HTML2PDFTest/NODEJS/HTML2PDFTest.js +166 -0
- package/samples/HTML2PDFTest/NODEJS/RunTest.sh +2 -0
- package/samples/HighlightsTest/HighlightsTest.js +1 -1
- package/samples/HighlightsTest/NODEJS/HighlightsTest.js +97 -0
- package/samples/HighlightsTest/NODEJS/RunTest.sh +2 -0
- package/samples/ImageExtractTest/ImageExtractTest.js +129 -129
- package/samples/ImageExtractTest/NODEJS/ImageExtractTest.js +130 -0
- package/samples/ImageExtractTest/NODEJS/RunTest.sh +2 -0
- package/samples/ImpositionTest/ImpositionTest.js +86 -86
- package/samples/ImpositionTest/NODEJS/ImpositionTest.js +87 -0
- package/samples/ImpositionTest/NODEJS/RunTest.sh +2 -0
- package/samples/InteractiveFormsTest/InteractiveFormsTest.js +381 -381
- package/samples/InteractiveFormsTest/NODEJS/InteractiveFormsTest.js +382 -0
- package/samples/InteractiveFormsTest/NODEJS/RunTest.sh +2 -0
- package/samples/JBIG2Test/JBIG2Test.js +88 -88
- package/samples/JBIG2Test/NODEJS/JBIG2Test.js +89 -0
- package/samples/JBIG2Test/NODEJS/RunTest.sh +2 -0
- package/samples/LicenseKey/NODEJS/LicenseKey.js +11 -0
- package/samples/LogicalStructureTest/LogicalStructureTest.js +1 -1
- package/samples/LogicalStructureTest/NODEJS/LogicalStructureTest.js +251 -0
- package/samples/LogicalStructureTest/NODEJS/RunTest.sh +2 -0
- package/samples/OCRTest/NODEJS/OCRTest.js +235 -0
- package/samples/OCRTest/NODEJS/RunTest.sh +2 -0
- package/samples/OCRTest/OCRTest.js +234 -234
- package/samples/OfficeTemplateTest/NODEJS/OfficeTemplateTest.js +79 -0
- package/samples/OfficeTemplateTest/NODEJS/RunTest.sh +2 -0
- package/samples/OfficeTemplateTest/OfficeTemplateTest.js +79 -77
- package/samples/OfficeToPDFTest/NODEJS/OfficeToPDFTest.js +125 -0
- package/samples/OfficeToPDFTest/NODEJS/RunTest.sh +2 -0
- package/samples/OfficeToPDFTest/OfficeToPDFTest.js +125 -125
- package/samples/OptimizerTest/NODEJS/OptimizerTest.js +192 -0
- package/samples/OptimizerTest/NODEJS/RunTest.sh +2 -0
- package/samples/OptimizerTest/OptimizerTest.js +191 -191
- package/samples/PDF2HtmlTest/NODEJS/PDF2HtmlTest.js +123 -0
- package/samples/PDF2HtmlTest/NODEJS/RunTest.sh +2 -0
- package/samples/PDF2HtmlTest/PDF2HtmlTest.js +1 -1
- package/samples/PDF2OfficeTest/NODEJS/PDF2OfficeTest.js +158 -0
- package/samples/PDF2OfficeTest/NODEJS/RunTest.sh +2 -0
- package/samples/PDF2OfficeTest/PDF2OfficeTest.js +1 -1
- package/samples/PDFATest/NODEJS/PDFATest.js +85 -0
- package/samples/PDFATest/NODEJS/RunTest.sh +2 -0
- package/samples/PDFATest/PDFATest.js +1 -1
- package/samples/PDFDocMemoryTest/NODEJS/PDFDocMemoryTest.js +85 -0
- package/samples/PDFDocMemoryTest/NODEJS/RunTest.sh +2 -0
- package/samples/PDFDocMemoryTest/PDFDocMemoryTest.js +84 -84
- package/samples/PDFDrawTest/NODEJS/PDFDrawTest.js +306 -0
- package/samples/PDFDrawTest/NODEJS/RunTest.sh +2 -0
- package/samples/PDFDrawTest/PDFDrawTest.js +1 -1
- package/samples/PDFLayersTest/NODEJS/PDFLayersTest.js +295 -0
- package/samples/PDFLayersTest/NODEJS/RunTest.sh +2 -0
- package/samples/PDFLayersTest/PDFLayersTest.js +1 -1
- package/samples/PDFPackageTest/NODEJS/PDFPackageTest.js +112 -0
- package/samples/PDFPackageTest/NODEJS/RunTest.sh +2 -0
- package/samples/PDFPackageTest/PDFPackageTest.js +111 -111
- package/samples/PDFPageTest/NODEJS/PDFPageTest.js +190 -0
- package/samples/PDFPageTest/NODEJS/RunTest.sh +2 -0
- package/samples/PDFPageTest/PDFPageTest.js +1 -1
- package/samples/PDFRedactTest/NODEJS/PDFRedactTest.js +75 -0
- package/samples/PDFRedactTest/NODEJS/RunTest.sh +2 -0
- package/samples/PDFRedactTest/PDFRedactTest.js +1 -1
- package/samples/PageLabelsTest/NODEJS/PageLabelsTest.js +139 -0
- package/samples/PageLabelsTest/NODEJS/RunTest.sh +2 -0
- package/samples/PageLabelsTest/PageLabelsTest.js +138 -138
- package/samples/PatternTest/NODEJS/PatternTest.js +227 -0
- package/samples/PatternTest/NODEJS/RunTest.sh +2 -0
- package/samples/PatternTest/PatternTest.js +226 -226
- package/samples/RectTest/NODEJS/RectTest.js +41 -0
- package/samples/RectTest/NODEJS/RunTest.sh +2 -0
- package/samples/RectTest/RectTest.js +1 -1
- package/samples/SDFTest/NODEJS/RunTest.sh +2 -0
- package/samples/SDFTest/NODEJS/SDFTest.js +88 -0
- package/samples/SDFTest/SDFTest.js +2 -3
- package/samples/StamperTest/NODEJS/RunTest.sh +2 -0
- package/samples/StamperTest/NODEJS/StamperTest.js +256 -0
- package/samples/StamperTest/StamperTest.js +1 -1
- package/samples/TestFiles/financial.pdf +0 -0
- package/samples/TestFiles/formfields-scanned.pdf +0 -0
- package/samples/TestFiles/formfields.pdf +0 -0
- package/samples/TestFiles/table.pdf +0 -0
- package/samples/TestFiles/tiger.svg +378 -0
- package/samples/TextExtractTest/NODEJS/RunTest.sh +2 -0
- package/samples/TextExtractTest/NODEJS/TextExtractTest.js +287 -0
- package/samples/TextExtractTest/TextExtractTest.js +1 -1
- package/samples/TextSearchTest/NODEJS/RunTest.sh +2 -0
- package/samples/TextSearchTest/NODEJS/TextSearchTest.js +122 -0
- package/samples/TextSearchTest/TextSearchTest.js +1 -1
- package/samples/U3DTest/NODEJS/RunTest.sh +2 -0
- package/samples/U3DTest/NODEJS/U3DTest.js +105 -0
- package/samples/U3DTest/U3DTest.js +104 -104
- package/samples/UndoRedoTest/NODEJS/RunTest.sh +2 -0
- package/samples/UndoRedoTest/NODEJS/UndoRedoTest.js +101 -0
- package/samples/UndoRedoTest/UndoRedoTest.js +1 -1
- package/samples/UnicodeWriteTest/NODEJS/RunTest.sh +2 -0
- package/samples/UnicodeWriteTest/NODEJS/UnicodeWriteTest.js +174 -0
- package/samples/UnicodeWriteTest/UnicodeWriteTest.js +1 -1
- package/samples/WebViewerConvertTest/NODEJS/RunTest.sh +2 -0
- package/samples/WebViewerConvertTest/NODEJS/WebViewerConvertTest.js +136 -0
- package/samples/WebViewerConvertTest/WebViewerConvertTest.js +135 -135
- package/samples/runall.bat +12 -12
|
@@ -0,0 +1,112 @@
|
|
|
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
|
+
/// This sample illustrates how to create, extract, and manipulate PDF Portfolios
|
|
8
|
+
/// (a.k.a. PDF Packages) using PDFNet SDK.
|
|
9
|
+
//-----------------------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
const { PDFNet } = require('../../../lib/pdfnet.js');
|
|
12
|
+
const PDFTronLicense = require('../../LicenseKey/NODEJS/LicenseKey');
|
|
13
|
+
|
|
14
|
+
((exports) => {
|
|
15
|
+
'use strict';
|
|
16
|
+
|
|
17
|
+
exports.runPDFPackageTest = () => {
|
|
18
|
+
// Relative path to the folder containing test files.
|
|
19
|
+
const inputPath = '../../TestFiles/';
|
|
20
|
+
const outputPath = inputPath + 'Output/';
|
|
21
|
+
|
|
22
|
+
const addPackage = async (doc, file, desc) => {
|
|
23
|
+
const files = await PDFNet.NameTree.create(doc, 'EmbeddedFiles');
|
|
24
|
+
const fs = await PDFNet.FileSpec.create(doc, file, true);
|
|
25
|
+
files.put(file, await fs.getSDFObj());
|
|
26
|
+
fs.setDesc(desc);
|
|
27
|
+
|
|
28
|
+
const root = await doc.getRoot();
|
|
29
|
+
let collection = await root.findObj('Collection');
|
|
30
|
+
if (!collection) collection = await root.putDict('Collection');
|
|
31
|
+
|
|
32
|
+
// You could here manipulate any entry in the Collection dictionary.
|
|
33
|
+
// For example, the following line sets the tile mode for initial view mode
|
|
34
|
+
// Please refer to section '2.3.5 Collections' in PDF Reference for details.
|
|
35
|
+
collection.putName('View', 'T');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const addCoverPage = async (doc) => {
|
|
39
|
+
// Here we dynamically generate cover page (please see ElementBuilder
|
|
40
|
+
// sample for more extensive coverage of PDF creation API).
|
|
41
|
+
const page = await doc.pageCreate(await PDFNet.Rect.init(0, 0, 200, 200));
|
|
42
|
+
|
|
43
|
+
const b = await PDFNet.ElementBuilder.create();
|
|
44
|
+
const w = await PDFNet.ElementWriter.create();
|
|
45
|
+
w.beginOnPage(page);
|
|
46
|
+
const font = await PDFNet.Font.create(doc, PDFNet.Font.StandardType1Font.e_helvetica);
|
|
47
|
+
w.writeElement(await b.createTextBeginWithFont(font, 12));
|
|
48
|
+
const e = await b.createNewTextRun('My PDF Collection');
|
|
49
|
+
e.setTextMatrixEntries(1, 0, 0, 1, 50, 96);
|
|
50
|
+
const gstate = await e.getGState();
|
|
51
|
+
gstate.setFillColorSpace(await PDFNet.ColorSpace.createDeviceRGB());
|
|
52
|
+
gstate.setFillColorWithColorPt(await PDFNet.ColorPt.init(1, 0, 0));
|
|
53
|
+
w.writeElement(e);
|
|
54
|
+
w.writeElement(await b.createTextEnd());
|
|
55
|
+
w.end();
|
|
56
|
+
doc.pagePushBack(page);
|
|
57
|
+
|
|
58
|
+
// Alternatively we could import a PDF page from a template PDF document
|
|
59
|
+
// (for an example please see PDFPage sample project).
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const main = async () => {
|
|
63
|
+
|
|
64
|
+
// Create a PDF Package.
|
|
65
|
+
try {
|
|
66
|
+
const doc = await PDFNet.PDFDoc.create();
|
|
67
|
+
await addPackage(doc, inputPath + 'numbered.pdf', 'My File 1');
|
|
68
|
+
await addPackage(doc, inputPath + 'newsletter.pdf', 'My Newsletter...');
|
|
69
|
+
await addPackage(doc, inputPath + 'peppers.jpg', 'An image');
|
|
70
|
+
await addCoverPage(doc);
|
|
71
|
+
await doc.save(outputPath + 'package.pdf', PDFNet.SDFDoc.SaveOptions.e_linearized);
|
|
72
|
+
console.log('Done.');
|
|
73
|
+
} catch (err) {
|
|
74
|
+
console.log(err);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
const doc = await PDFNet.PDFDoc.createFromFilePath(outputPath + 'package.pdf');
|
|
79
|
+
await doc.initSecurityHandler();
|
|
80
|
+
|
|
81
|
+
const files = await PDFNet.NameTree.find(doc, 'EmbeddedFiles');
|
|
82
|
+
if (await files.isValid()) {
|
|
83
|
+
// Traverse the list of embedded files.
|
|
84
|
+
const i = await files.getIteratorBegin();
|
|
85
|
+
for (var counter = 0; await i.hasNext(); await i.next(), ++counter) {
|
|
86
|
+
const entry_name = await i.key().then(key => key.getAsPDFText());
|
|
87
|
+
console.log('Part: ' + entry_name);
|
|
88
|
+
const file_spec = await PDFNet.FileSpec.createFromObj(await i.value());
|
|
89
|
+
const stm = await file_spec.getFileData();
|
|
90
|
+
if (stm) {
|
|
91
|
+
let ext = '.pdf';
|
|
92
|
+
if (entry_name.includes('.')) {
|
|
93
|
+
ext = entry_name.substr(entry_name.lastIndexOf('.'));
|
|
94
|
+
}
|
|
95
|
+
stm.writeToFile(outputPath + 'extract_' + counter + ext, false);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
console.log('Done.');
|
|
101
|
+
} catch (err) {
|
|
102
|
+
console.log(err);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error) {
|
|
106
|
+
console.log('Error: ' + JSON.stringify(error));
|
|
107
|
+
}).then(function(){ return PDFNet.shutdown(); });
|
|
108
|
+
};
|
|
109
|
+
exports.runPDFPackageTest();
|
|
110
|
+
})(exports);
|
|
111
|
+
// eslint-disable-next-line spaced-comment
|
|
112
|
+
//# sourceURL=PDFPackageTest.js
|
|
@@ -1,112 +1,112 @@
|
|
|
1
|
-
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-
|
|
3
|
-
// Consult legal.txt regarding legal and license information.
|
|
4
|
-
//---------------------------------------------------------------------------------------
|
|
5
|
-
|
|
6
|
-
//-----------------------------------------------------------------------------------
|
|
7
|
-
/// This sample illustrates how to create, extract, and manipulate PDF Portfolios
|
|
8
|
-
/// (a.k.a. PDF Packages) using PDFNet SDK.
|
|
9
|
-
//-----------------------------------------------------------------------------------
|
|
10
|
-
|
|
11
|
-
const { PDFNet } = require('@pdftron/pdfnet-node');
|
|
12
|
-
const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
13
|
-
|
|
14
|
-
((exports) => {
|
|
15
|
-
'use strict';
|
|
16
|
-
|
|
17
|
-
exports.runPDFPackageTest = () => {
|
|
18
|
-
// Relative path to the folder containing test files.
|
|
19
|
-
const inputPath = '../TestFiles/';
|
|
20
|
-
const outputPath = inputPath + 'Output/';
|
|
21
|
-
|
|
22
|
-
const addPackage = async (doc, file, desc) => {
|
|
23
|
-
const files = await PDFNet.NameTree.create(doc, 'EmbeddedFiles');
|
|
24
|
-
const fs = await PDFNet.FileSpec.create(doc, file, true);
|
|
25
|
-
files.put(file, await fs.getSDFObj());
|
|
26
|
-
fs.setDesc(desc);
|
|
27
|
-
|
|
28
|
-
const root = await doc.getRoot();
|
|
29
|
-
let collection = await root.findObj('Collection');
|
|
30
|
-
if (!collection) collection = await root.putDict('Collection');
|
|
31
|
-
|
|
32
|
-
// You could here manipulate any entry in the Collection dictionary.
|
|
33
|
-
// For example, the following line sets the tile mode for initial view mode
|
|
34
|
-
// Please refer to section '2.3.5 Collections' in PDF Reference for details.
|
|
35
|
-
collection.putName('View', 'T');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const addCoverPage = async (doc) => {
|
|
39
|
-
// Here we dynamically generate cover page (please see ElementBuilder
|
|
40
|
-
// sample for more extensive coverage of PDF creation API).
|
|
41
|
-
const page = await doc.pageCreate(await PDFNet.Rect.init(0, 0, 200, 200));
|
|
42
|
-
|
|
43
|
-
const b = await PDFNet.ElementBuilder.create();
|
|
44
|
-
const w = await PDFNet.ElementWriter.create();
|
|
45
|
-
w.beginOnPage(page);
|
|
46
|
-
const font = await PDFNet.Font.create(doc, PDFNet.Font.StandardType1Font.e_helvetica);
|
|
47
|
-
w.writeElement(await b.createTextBeginWithFont(font, 12));
|
|
48
|
-
const e = await b.createNewTextRun('My PDF Collection');
|
|
49
|
-
e.setTextMatrixEntries(1, 0, 0, 1, 50, 96);
|
|
50
|
-
const gstate = await e.getGState();
|
|
51
|
-
gstate.setFillColorSpace(await PDFNet.ColorSpace.createDeviceRGB());
|
|
52
|
-
gstate.setFillColorWithColorPt(await PDFNet.ColorPt.init(1, 0, 0));
|
|
53
|
-
w.writeElement(e);
|
|
54
|
-
w.writeElement(await b.createTextEnd());
|
|
55
|
-
w.end();
|
|
56
|
-
doc.pagePushBack(page);
|
|
57
|
-
|
|
58
|
-
// Alternatively we could import a PDF page from a template PDF document
|
|
59
|
-
// (for an example please see PDFPage sample project).
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const main = async () => {
|
|
63
|
-
|
|
64
|
-
// Create a PDF Package.
|
|
65
|
-
try {
|
|
66
|
-
const doc = await PDFNet.PDFDoc.create();
|
|
67
|
-
await addPackage(doc, inputPath + 'numbered.pdf', 'My File 1');
|
|
68
|
-
await addPackage(doc, inputPath + 'newsletter.pdf', 'My Newsletter...');
|
|
69
|
-
await addPackage(doc, inputPath + 'peppers.jpg', 'An image');
|
|
70
|
-
await addCoverPage(doc);
|
|
71
|
-
await doc.save(outputPath + 'package.pdf', PDFNet.SDFDoc.SaveOptions.e_linearized);
|
|
72
|
-
console.log('Done.');
|
|
73
|
-
} catch (err) {
|
|
74
|
-
console.log(err);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
try {
|
|
78
|
-
const doc = await PDFNet.PDFDoc.createFromFilePath(outputPath + 'package.pdf');
|
|
79
|
-
await doc.initSecurityHandler();
|
|
80
|
-
|
|
81
|
-
const files = await PDFNet.NameTree.find(doc, 'EmbeddedFiles');
|
|
82
|
-
if (await files.isValid()) {
|
|
83
|
-
// Traverse the list of embedded files.
|
|
84
|
-
const i = await files.getIteratorBegin();
|
|
85
|
-
for (var counter = 0; await i.hasNext(); await i.next(), ++counter) {
|
|
86
|
-
const entry_name = await i.key().then(key => key.getAsPDFText());
|
|
87
|
-
console.log('Part: ' + entry_name);
|
|
88
|
-
const file_spec = await PDFNet.FileSpec.createFromObj(await i.value());
|
|
89
|
-
const stm = await file_spec.getFileData();
|
|
90
|
-
if (stm) {
|
|
91
|
-
let ext = '.pdf';
|
|
92
|
-
if (entry_name.includes('.')) {
|
|
93
|
-
ext = entry_name.substr(entry_name.lastIndexOf('.'));
|
|
94
|
-
}
|
|
95
|
-
stm.writeToFile(outputPath + 'extract_' + counter + ext, false);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
console.log('Done.');
|
|
101
|
-
} catch (err) {
|
|
102
|
-
console.log(err);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error) {
|
|
106
|
-
console.log('Error: ' + JSON.stringify(error));
|
|
107
|
-
}).then(function(){ return PDFNet.shutdown(); });
|
|
108
|
-
};
|
|
109
|
-
exports.runPDFPackageTest();
|
|
110
|
-
})(exports);
|
|
111
|
-
// eslint-disable-next-line spaced-comment
|
|
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
|
+
/// This sample illustrates how to create, extract, and manipulate PDF Portfolios
|
|
8
|
+
/// (a.k.a. PDF Packages) using PDFNet SDK.
|
|
9
|
+
//-----------------------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
const { PDFNet } = require('@pdftron/pdfnet-node');
|
|
12
|
+
const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
13
|
+
|
|
14
|
+
((exports) => {
|
|
15
|
+
'use strict';
|
|
16
|
+
|
|
17
|
+
exports.runPDFPackageTest = () => {
|
|
18
|
+
// Relative path to the folder containing test files.
|
|
19
|
+
const inputPath = '../TestFiles/';
|
|
20
|
+
const outputPath = inputPath + 'Output/';
|
|
21
|
+
|
|
22
|
+
const addPackage = async (doc, file, desc) => {
|
|
23
|
+
const files = await PDFNet.NameTree.create(doc, 'EmbeddedFiles');
|
|
24
|
+
const fs = await PDFNet.FileSpec.create(doc, file, true);
|
|
25
|
+
files.put(file, await fs.getSDFObj());
|
|
26
|
+
fs.setDesc(desc);
|
|
27
|
+
|
|
28
|
+
const root = await doc.getRoot();
|
|
29
|
+
let collection = await root.findObj('Collection');
|
|
30
|
+
if (!collection) collection = await root.putDict('Collection');
|
|
31
|
+
|
|
32
|
+
// You could here manipulate any entry in the Collection dictionary.
|
|
33
|
+
// For example, the following line sets the tile mode for initial view mode
|
|
34
|
+
// Please refer to section '2.3.5 Collections' in PDF Reference for details.
|
|
35
|
+
collection.putName('View', 'T');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const addCoverPage = async (doc) => {
|
|
39
|
+
// Here we dynamically generate cover page (please see ElementBuilder
|
|
40
|
+
// sample for more extensive coverage of PDF creation API).
|
|
41
|
+
const page = await doc.pageCreate(await PDFNet.Rect.init(0, 0, 200, 200));
|
|
42
|
+
|
|
43
|
+
const b = await PDFNet.ElementBuilder.create();
|
|
44
|
+
const w = await PDFNet.ElementWriter.create();
|
|
45
|
+
w.beginOnPage(page);
|
|
46
|
+
const font = await PDFNet.Font.create(doc, PDFNet.Font.StandardType1Font.e_helvetica);
|
|
47
|
+
w.writeElement(await b.createTextBeginWithFont(font, 12));
|
|
48
|
+
const e = await b.createNewTextRun('My PDF Collection');
|
|
49
|
+
e.setTextMatrixEntries(1, 0, 0, 1, 50, 96);
|
|
50
|
+
const gstate = await e.getGState();
|
|
51
|
+
gstate.setFillColorSpace(await PDFNet.ColorSpace.createDeviceRGB());
|
|
52
|
+
gstate.setFillColorWithColorPt(await PDFNet.ColorPt.init(1, 0, 0));
|
|
53
|
+
w.writeElement(e);
|
|
54
|
+
w.writeElement(await b.createTextEnd());
|
|
55
|
+
w.end();
|
|
56
|
+
doc.pagePushBack(page);
|
|
57
|
+
|
|
58
|
+
// Alternatively we could import a PDF page from a template PDF document
|
|
59
|
+
// (for an example please see PDFPage sample project).
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const main = async () => {
|
|
63
|
+
|
|
64
|
+
// Create a PDF Package.
|
|
65
|
+
try {
|
|
66
|
+
const doc = await PDFNet.PDFDoc.create();
|
|
67
|
+
await addPackage(doc, inputPath + 'numbered.pdf', 'My File 1');
|
|
68
|
+
await addPackage(doc, inputPath + 'newsletter.pdf', 'My Newsletter...');
|
|
69
|
+
await addPackage(doc, inputPath + 'peppers.jpg', 'An image');
|
|
70
|
+
await addCoverPage(doc);
|
|
71
|
+
await doc.save(outputPath + 'package.pdf', PDFNet.SDFDoc.SaveOptions.e_linearized);
|
|
72
|
+
console.log('Done.');
|
|
73
|
+
} catch (err) {
|
|
74
|
+
console.log(err);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
const doc = await PDFNet.PDFDoc.createFromFilePath(outputPath + 'package.pdf');
|
|
79
|
+
await doc.initSecurityHandler();
|
|
80
|
+
|
|
81
|
+
const files = await PDFNet.NameTree.find(doc, 'EmbeddedFiles');
|
|
82
|
+
if (await files.isValid()) {
|
|
83
|
+
// Traverse the list of embedded files.
|
|
84
|
+
const i = await files.getIteratorBegin();
|
|
85
|
+
for (var counter = 0; await i.hasNext(); await i.next(), ++counter) {
|
|
86
|
+
const entry_name = await i.key().then(key => key.getAsPDFText());
|
|
87
|
+
console.log('Part: ' + entry_name);
|
|
88
|
+
const file_spec = await PDFNet.FileSpec.createFromObj(await i.value());
|
|
89
|
+
const stm = await file_spec.getFileData();
|
|
90
|
+
if (stm) {
|
|
91
|
+
let ext = '.pdf';
|
|
92
|
+
if (entry_name.includes('.')) {
|
|
93
|
+
ext = entry_name.substr(entry_name.lastIndexOf('.'));
|
|
94
|
+
}
|
|
95
|
+
stm.writeToFile(outputPath + 'extract_' + counter + ext, false);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
console.log('Done.');
|
|
101
|
+
} catch (err) {
|
|
102
|
+
console.log(err);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error) {
|
|
106
|
+
console.log('Error: ' + JSON.stringify(error));
|
|
107
|
+
}).then(function(){ return PDFNet.shutdown(); });
|
|
108
|
+
};
|
|
109
|
+
exports.runPDFPackageTest();
|
|
110
|
+
})(exports);
|
|
111
|
+
// eslint-disable-next-line spaced-comment
|
|
112
112
|
//# sourceURL=PDFPackageTest.js
|
|
@@ -0,0 +1,190 @@
|
|
|
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
|
+
const { PDFNet } = require('../../../lib/pdfnet.js');
|
|
7
|
+
const PDFTronLicense = require('../../LicenseKey/NODEJS/LicenseKey');
|
|
8
|
+
|
|
9
|
+
((exports) => {
|
|
10
|
+
|
|
11
|
+
exports.runPDFPageTest = () => {
|
|
12
|
+
|
|
13
|
+
const main = async () => {
|
|
14
|
+
// Relative path to the folder containing test files.
|
|
15
|
+
const inputPath = '../../TestFiles/';
|
|
16
|
+
const outputPath = inputPath + 'Output/';
|
|
17
|
+
|
|
18
|
+
// Sample 1 - Split a PDF document into multiple pages
|
|
19
|
+
try {
|
|
20
|
+
console.log('_______________________________________________');
|
|
21
|
+
console.log('Sample 1 - Split a PDF document into multiple pages...');
|
|
22
|
+
console.log('Opening the input pdf...');
|
|
23
|
+
const inDoc = await PDFNet.PDFDoc.createFromFilePath(inputPath + 'newsletter.pdf');
|
|
24
|
+
inDoc.initSecurityHandler();
|
|
25
|
+
|
|
26
|
+
const pageCount = await inDoc.getPageCount();
|
|
27
|
+
for (let i = 1; i <= pageCount; ++i) {
|
|
28
|
+
const newDoc = await PDFNet.PDFDoc.create();
|
|
29
|
+
const filename = 'newsletter_split_page_' + i + '.pdf';
|
|
30
|
+
newDoc.insertPages(0, inDoc, i, i, PDFNet.PDFDoc.InsertFlag.e_none);
|
|
31
|
+
await newDoc.save(outputPath + filename, PDFNet.SDFDoc.SaveOptions.e_remove_unused);
|
|
32
|
+
console.log('Done. Result saved in ' + filename);
|
|
33
|
+
}
|
|
34
|
+
} catch (err) {
|
|
35
|
+
// console.log(err);
|
|
36
|
+
console.log(err.stack);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Sample 2 - Merge several PDF documents into one
|
|
40
|
+
try {
|
|
41
|
+
console.log('_______________________________________________');
|
|
42
|
+
console.log('Sample 2 - Merge several PDF documents into one...');
|
|
43
|
+
|
|
44
|
+
// start stack-based deallocation with startDeallocateStack. Later on when endDeallocateStack is called,
|
|
45
|
+
// all objects in memory that were initialized since the most recent startDeallocateStack call will be
|
|
46
|
+
// cleaned up. Doing this makes sure that memory growth does not get too high.
|
|
47
|
+
await PDFNet.startDeallocateStack();
|
|
48
|
+
const newDoc = await PDFNet.PDFDoc.create();
|
|
49
|
+
newDoc.initSecurityHandler();
|
|
50
|
+
|
|
51
|
+
const pageNum = 15
|
|
52
|
+
for (let i = 1; i <= pageNum; ++i) {
|
|
53
|
+
const fname = 'newsletter_split_page_' + i + '.pdf';
|
|
54
|
+
console.log('Opening ' + fname);
|
|
55
|
+
const currDoc = await PDFNet.PDFDoc.createFromFilePath(outputPath + fname);
|
|
56
|
+
const currDocPageCount = await currDoc.getPageCount();
|
|
57
|
+
newDoc.insertPages(i, currDoc, 1, currDocPageCount, PDFNet.PDFDoc.InsertFlag.e_none);
|
|
58
|
+
}
|
|
59
|
+
await newDoc.save(outputPath + 'newsletter_merge_pages.pdf', PDFNet.SDFDoc.SaveOptions.e_remove_unused);
|
|
60
|
+
console.log('Done. Result saved in newsletter_merge_pages.pdf');
|
|
61
|
+
await PDFNet.endDeallocateStack();
|
|
62
|
+
} catch (err) {
|
|
63
|
+
// console.log(err);
|
|
64
|
+
console.log(err.stack);
|
|
65
|
+
ret = 1;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Sample 3 - Delete every second page
|
|
69
|
+
try {
|
|
70
|
+
console.log('_______________________________________________');
|
|
71
|
+
console.log('Sample 3 - Delete every second page...');
|
|
72
|
+
console.log('Opening the input pdf...');
|
|
73
|
+
await PDFNet.startDeallocateStack();
|
|
74
|
+
const inDoc = await PDFNet.PDFDoc.createFromFilePath(inputPath + 'newsletter.pdf');
|
|
75
|
+
inDoc.initSecurityHandler();
|
|
76
|
+
|
|
77
|
+
let pageNum = await inDoc.getPageCount();
|
|
78
|
+
|
|
79
|
+
while (pageNum >= 1) {
|
|
80
|
+
const itr = await inDoc.getPageIterator(pageNum);
|
|
81
|
+
inDoc.pageRemove(itr);
|
|
82
|
+
pageNum -= 2;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
await inDoc.save(outputPath + 'newsletter_page_remove.pdf', 0);
|
|
86
|
+
console.log('Done. Result saved in newsletter_page_remove.pdf...');
|
|
87
|
+
await PDFNet.endDeallocateStack();
|
|
88
|
+
} catch (err) {
|
|
89
|
+
console.log(err);
|
|
90
|
+
ret = 1;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Sample 4 - Inserts a page from one document at different
|
|
94
|
+
// locations within another document
|
|
95
|
+
try {
|
|
96
|
+
console.log('_______________________________________________');
|
|
97
|
+
console.log('Sample 4 - Insert a page at different locations...');
|
|
98
|
+
console.log('Opening the input pdf...');
|
|
99
|
+
await PDFNet.startDeallocateStack();
|
|
100
|
+
const in1Doc = await PDFNet.PDFDoc.createFromFilePath(inputPath + 'newsletter.pdf');
|
|
101
|
+
in1Doc.initSecurityHandler();
|
|
102
|
+
|
|
103
|
+
const in2Doc = await PDFNet.PDFDoc.createFromFilePath(inputPath + 'fish.pdf');
|
|
104
|
+
in2Doc.initSecurityHandler();
|
|
105
|
+
|
|
106
|
+
const srcPage = await in2Doc.getPageIterator();
|
|
107
|
+
const dstPage = await in1Doc.getPageIterator();
|
|
108
|
+
let pageNum = 1;
|
|
109
|
+
while (await dstPage.hasNext()) {
|
|
110
|
+
if (pageNum++ % 3 === 0) {
|
|
111
|
+
in1Doc.pageInsert(dstPage, await srcPage.current());
|
|
112
|
+
}
|
|
113
|
+
dstPage.next();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
await in1Doc.save(outputPath + 'newsletter_page_insert.pdf', 0);
|
|
117
|
+
console.log('Done. Result saved in newsletter_page_insert.pdf...');
|
|
118
|
+
await PDFNet.endDeallocateStack();
|
|
119
|
+
} catch (err) {
|
|
120
|
+
console.log(err.stack);
|
|
121
|
+
ret = 1;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Sample 5 - Replicate pages within a single document
|
|
125
|
+
try {
|
|
126
|
+
console.log('_______________________________________________');
|
|
127
|
+
console.log('Sample 5 - Replicate pages within a single document...');
|
|
128
|
+
console.log('Opening the input pdf...');
|
|
129
|
+
await PDFNet.startDeallocateStack();
|
|
130
|
+
const doc = await PDFNet.PDFDoc.createFromFilePath(inputPath + 'newsletter.pdf');
|
|
131
|
+
doc.initSecurityHandler();
|
|
132
|
+
|
|
133
|
+
// Replicate the cover page three times (copy page #1 and place it before the
|
|
134
|
+
// seventh page in the document page sequence)
|
|
135
|
+
const cover = await doc.getPage(1);
|
|
136
|
+
const p7 = await doc.getPageIterator(7);
|
|
137
|
+
doc.pageInsert(p7, cover);
|
|
138
|
+
doc.pageInsert(p7, cover);
|
|
139
|
+
doc.pageInsert(p7, cover);
|
|
140
|
+
// replicate cover page two more times by placing it before and after existing pages
|
|
141
|
+
doc.pagePushFront(cover);
|
|
142
|
+
doc.pagePushBack(cover);
|
|
143
|
+
|
|
144
|
+
await doc.save(outputPath + 'newsletter_page_clone.pdf', 0);
|
|
145
|
+
console.log('Done. Result saved in newsletter_page_clone.pdf...');
|
|
146
|
+
await PDFNet.endDeallocateStack();
|
|
147
|
+
} catch (err) {
|
|
148
|
+
console.log(err.stack);
|
|
149
|
+
ret = 1;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Sample 6 - Use ImportPages() in order to copy multiple pages at once
|
|
153
|
+
// in order to preserve shared resources between pages (e.g. images, fonts,
|
|
154
|
+
// colorspaces, etc.)
|
|
155
|
+
try {
|
|
156
|
+
console.log('_______________________________________________');
|
|
157
|
+
console.log('Sample 6 - Preserving shared resources using ImportPages...');
|
|
158
|
+
console.log('Opening the input pdf...');
|
|
159
|
+
const in_doc = await PDFNet.PDFDoc.createFromFilePath(inputPath + 'newsletter.pdf');
|
|
160
|
+
in_doc.initSecurityHandler();
|
|
161
|
+
|
|
162
|
+
const new_doc = await PDFNet.PDFDoc.create();
|
|
163
|
+
|
|
164
|
+
const copy_pages = [];
|
|
165
|
+
for (const itr = await in_doc.getPageIterator(); await itr.hasNext(); await itr.next()) {
|
|
166
|
+
copy_pages.push(await itr.current());
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const imported_pages = await new_doc.importPages(copy_pages);
|
|
170
|
+
for (var i = 0; i < imported_pages.length; ++i) {
|
|
171
|
+
new_doc.pagePushFront(imported_pages[i]); // Order pages in reverse order.
|
|
172
|
+
// Use PagePushBack() if you would like to preserve the same order.
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
await new_doc.save(outputPath + 'newsletter_import_pages.pdf', 0);
|
|
176
|
+
console.log('Done. Result saved in newsletter_import_pages.pdf...\n');
|
|
177
|
+
console.log('Note that the output file size is less than half the size\n'
|
|
178
|
+
+ 'of the file produced using individual page copy operations\n'
|
|
179
|
+
+ 'between two documents');
|
|
180
|
+
} catch (err) {
|
|
181
|
+
console.log(err.stack);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) { console.log('Error: ' + JSON.stringify(error)); }).then(function () { return PDFNet.shutdown(); });
|
|
186
|
+
};
|
|
187
|
+
exports.runPDFPageTest();
|
|
188
|
+
})(exports);
|
|
189
|
+
// eslint-disable-next-line spaced-comment
|
|
190
|
+
//# sourceURL=PDFPageTest.js
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-
|
|
2
|
+
// Copyright (c) 2001-2023 by PDFTron Systems Inc. All Rights Reserved.
|
|
3
3
|
// Consult legal.txt regarding legal and license information.
|
|
4
4
|
//---------------------------------------------------------------------------------------
|
|
5
5
|
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
// PDF Redactor is a separately licensable Add-on that offers options to remove
|
|
7
|
+
// (not just covering or obscuring) content within a region of PDF.
|
|
8
|
+
// With printed pages, redaction involves blacking-out or cutting-out areas of
|
|
9
|
+
// the printed page. With electronic documents that use formats such as PDF,
|
|
10
|
+
// redaction typically involves removing sensitive content within documents for
|
|
11
|
+
// safe distribution to courts, patent and government institutions, the media,
|
|
12
|
+
// customers, vendors or any other audience with restricted access to the content.
|
|
13
|
+
//
|
|
14
|
+
// The redaction process in PDFNet consists of two steps:
|
|
15
|
+
//
|
|
16
|
+
// a) Content identification: A user applies redact annotations that specify the
|
|
17
|
+
// pieces or regions of content that should be removed. The content for redaction
|
|
18
|
+
// can be identified either interactively (e.g. using 'pdftron.PDF.PDFViewCtrl'
|
|
19
|
+
// as shown in PDFView sample) or programmatically (e.g. using 'pdftron.PDF.TextSearch'
|
|
20
|
+
// or 'pdftron.PDF.TextExtractor'). Up until the next step is performed, the user
|
|
21
|
+
// can see, move and redefine these annotations.
|
|
22
|
+
// b) Content removal: Using 'pdftron.PDF.Redactor.Redact()' the user instructs
|
|
23
|
+
// PDFNet to apply the redact regions, after which the content in the area specified
|
|
24
|
+
// by the redact annotations is removed. The redaction function includes number of
|
|
25
|
+
// options to control the style of the redaction overlay (including color, text,
|
|
26
|
+
// font, border, transparency, etc.).
|
|
27
|
+
//
|
|
28
|
+
// PDFTron Redactor makes sure that if a portion of an image, text, or vector graphics
|
|
29
|
+
// is contained in a redaction region, that portion of the image or path data is
|
|
30
|
+
// destroyed and is not simply hidden with clipping or image masks. PDFNet API can also
|
|
31
|
+
// be used to review and remove metadata and other content that can exist in a PDF
|
|
32
|
+
// document, including XML Forms Architecture (XFA) content and Extensible Metadata
|
|
33
|
+
// Platform (XMP) content.
|
|
34
|
+
|
|
35
|
+
const { PDFNet } = require('../../../lib/pdfnet.js');
|
|
36
|
+
const PDFTronLicense = require('../../LicenseKey/NODEJS/LicenseKey');
|
|
37
|
+
|
|
38
|
+
((exports) => {
|
|
39
|
+
|
|
40
|
+
exports.runPDFRedactTest = () => {
|
|
41
|
+
const redact = async(input, output, vec, app) => {
|
|
42
|
+
const doc = await PDFNet.PDFDoc.createFromFilePath(input);
|
|
43
|
+
if (await doc.initSecurityHandler()) {
|
|
44
|
+
PDFNet.Redactor.redact(doc, vec, app, false, true);
|
|
45
|
+
await doc.save(output, PDFNet.SDFDoc.SaveOptions.e_linearized);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const main = async() => {
|
|
50
|
+
// Relative path to the folder containing test files.
|
|
51
|
+
const inputPath = '../../TestFiles/';
|
|
52
|
+
try {
|
|
53
|
+
const redactionArray = []; // we will contain a list of redaction objects in this array
|
|
54
|
+
redactionArray.push(await PDFNet.Redactor.redactionCreate(1, (await PDFNet.Rect.init(100, 100, 550, 600)), false, 'Top Secret'));
|
|
55
|
+
redactionArray.push(await PDFNet.Redactor.redactionCreate(2, (await PDFNet.Rect.init(30, 30, 450, 450)), true, 'Negative Redaction'));
|
|
56
|
+
redactionArray.push(await PDFNet.Redactor.redactionCreate(2, (await PDFNet.Rect.init(0, 0, 100, 100)), false, 'Positive'));
|
|
57
|
+
redactionArray.push(await PDFNet.Redactor.redactionCreate(2, (await PDFNet.Rect.init(100, 100, 200, 200)), false, 'Positive'));
|
|
58
|
+
redactionArray.push(await PDFNet.Redactor.redactionCreate(2, (await PDFNet.Rect.init(300, 300, 400, 400)), false, ''));
|
|
59
|
+
redactionArray.push(await PDFNet.Redactor.redactionCreate(2, (await PDFNet.Rect.init(500, 500, 600, 600)), false, ''));
|
|
60
|
+
redactionArray.push(await PDFNet.Redactor.redactionCreate(3, (await PDFNet.Rect.init(0, 0, 700, 20)), false, ''));
|
|
61
|
+
|
|
62
|
+
const appear = { redaction_overlay: true, border: false, show_redacted_content_regions: true };
|
|
63
|
+
await redact(inputPath + 'newsletter.pdf', inputPath + 'Output/redacted.pdf', redactionArray, appear);
|
|
64
|
+
|
|
65
|
+
console.log('Done...');
|
|
66
|
+
} catch (err) {
|
|
67
|
+
console.log(err.stack);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error){console.log('Error: ' + JSON.stringify(error));}).then(function(){return PDFNet.shutdown();});
|
|
71
|
+
};
|
|
72
|
+
exports.runPDFRedactTest();
|
|
73
|
+
})(exports);
|
|
74
|
+
// eslint-disable-next-line spaced-comment
|
|
75
|
+
//# sourceURL=PDFRedactTest.js
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-
|
|
2
|
+
// Copyright (c) 2001-2023 by PDFTron Systems Inc. All Rights Reserved.
|
|
3
3
|
// Consult legal.txt regarding legal and license information.
|
|
4
4
|
//---------------------------------------------------------------------------------------
|
|
5
5
|
|