@pdftron/pdfnet-node-samples 10.7.0 → 10.8.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.
Files changed (59) hide show
  1. package/package.json +21 -20
  2. package/readme.md +12 -12
  3. package/samples/AddImageTest/AddImageTest.js +115 -115
  4. package/samples/AdvancedImagingTest/AdvancedImagingTest.js +78 -78
  5. package/samples/AnnotationTest/AnnotationTest.js +641 -641
  6. package/samples/BookmarkTest/BookmarkTest.js +219 -219
  7. package/samples/CAD2PDFTest/CAD2PDFTest.js +79 -79
  8. package/samples/ContentReplacerTest/ContentReplacerTest.js +75 -75
  9. package/samples/ConvertPrintTest/ConvertPrintTest.js +153 -153
  10. package/samples/ConvertTest/ConvertTest.js +203 -203
  11. package/samples/DataExtractionTest/DataExtractionTest.js +214 -214
  12. package/samples/DigitalSignaturesTest/DigitalSignaturesTest.js +526 -526
  13. package/samples/DocumentCreationTest/DocumentCreationTest.js +409 -409
  14. package/samples/ElementBuilderTest/ElementBuilderTest.js +513 -513
  15. package/samples/ElementEditTest/ElementEditTest.js +110 -110
  16. package/samples/ElementReaderAdvTest/ElementReaderAdvTest.js +305 -305
  17. package/samples/ElementReaderTest/ElementReaderTest.js +77 -77
  18. package/samples/EncTest/EncTest.js +175 -175
  19. package/samples/FDFTest/FDFTest.js +218 -218
  20. package/samples/HTML2PDFTest/HTML2PDFTest.js +164 -164
  21. package/samples/HighlightsTest/HighlightsTest.js +97 -97
  22. package/samples/ImageExtractTest/ImageExtractTest.js +129 -129
  23. package/samples/ImpositionTest/ImpositionTest.js +86 -86
  24. package/samples/InteractiveFormsTest/InteractiveFormsTest.js +381 -381
  25. package/samples/JBIG2Test/JBIG2Test.js +88 -88
  26. package/samples/LicenseKey/LicenseKey.js +11 -11
  27. package/samples/LogicalStructureTest/LogicalStructureTest.js +250 -250
  28. package/samples/OCRTest/OCRTest.js +235 -235
  29. package/samples/OfficeTemplateTest/OfficeTemplateTest.js +79 -79
  30. package/samples/OfficeToPDFTest/OfficeToPDFTest.js +125 -125
  31. package/samples/OptimizerTest/OptimizerTest.js +191 -191
  32. package/samples/PDF2HtmlTest/PDF2HtmlTest.js +123 -123
  33. package/samples/PDF2OfficeTest/PDF2OfficeTest.js +158 -158
  34. package/samples/PDFATest/PDFATest.js +85 -85
  35. package/samples/PDFDocMemoryTest/PDFDocMemoryTest.js +84 -84
  36. package/samples/PDFDrawTest/PDFDrawTest.js +305 -305
  37. package/samples/PDFLayersTest/PDFLayersTest.js +294 -294
  38. package/samples/PDFPackageTest/PDFPackageTest.js +111 -111
  39. package/samples/PDFPageTest/PDFPageTest.js +189 -189
  40. package/samples/PDFRedactTest/PDFRedactTest.js +74 -74
  41. package/samples/PageLabelsTest/PageLabelsTest.js +138 -138
  42. package/samples/PatternTest/PatternTest.js +226 -226
  43. package/samples/RectTest/RectTest.js +40 -40
  44. package/samples/SDFTest/SDFTest.js +87 -87
  45. package/samples/StamperTest/StamperTest.js +255 -255
  46. package/samples/TestFiles/Misc-Fixed.pfa +1166 -1166
  47. package/samples/TestFiles/SHA-2 Root USERTrust RSA CA Sectigo timestamping.crt +34 -34
  48. package/samples/TestFiles/form1_annots.xfdf +33 -33
  49. package/samples/TestFiles/form1_data.xfdf +139 -139
  50. package/samples/TestFiles/my_stream.txt +2310 -2310
  51. package/samples/TestFiles/tiger.svg +378 -378
  52. package/samples/TextExtractTest/TextExtractTest.js +286 -286
  53. package/samples/TextSearchTest/TextSearchTest.js +121 -121
  54. package/samples/U3DTest/U3DTest.js +104 -104
  55. package/samples/UndoRedoTest/UndoRedoTest.js +101 -101
  56. package/samples/UnicodeWriteTest/UnicodeWriteTest.js +173 -173
  57. package/samples/WebViewerConvertTest/WebViewerConvertTest.js +135 -135
  58. package/samples/runall.bat +12 -12
  59. package/samples/runall.sh +15 -15
@@ -1,75 +1,75 @@
1
- //---------------------------------------------------------------------------------------
2
- // Copyright (c) 2001-2024 by Apryse Software 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('@pdftron/pdfnet-node');
36
- const PDFTronLicense = require('../LicenseKey/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
1
+ //---------------------------------------------------------------------------------------
2
+ // Copyright (c) 2001-2024 by Apryse Software 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('@pdftron/pdfnet-node');
36
+ const PDFTronLicense = require('../LicenseKey/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
75
  //# sourceURL=PDFRedactTest.js
@@ -1,139 +1,139 @@
1
- //---------------------------------------------------------------------------------------
2
- // Copyright (c) 2001-2024 by Apryse Software Inc. All Rights Reserved.
3
- // Consult legal.txt regarding legal and license information.
4
- //---------------------------------------------------------------------------------------
5
-
6
- //-----------------------------------------------------------------------------------
7
- // The sample illustrates how to work with PDF page labels.
8
- //
9
- // PDF page labels can be used to describe a page. This is used to
10
- // allow for non-sequential page numbering or the addition of arbitrary
11
- // labels for a page (such as the inclusion of Roman numerals at the
12
- // beginning of a book). PDFNet PageLabel object can be used to specify
13
- // the numbering style to use (for example, upper- or lower-case Roman,
14
- // decimal, and so forth), the starting number for the first page,
15
- // and an arbitrary prefix to be pre-appended to each number (for
16
- // example, 'A-' to generate 'A-1', 'A-2', 'A-3', and so forth.)
17
- //-----------------------------------------------------------------------------------
18
-
19
- const { PDFNet } = require('@pdftron/pdfnet-node');
20
- const PDFTronLicense = require('../LicenseKey/LicenseKey');
21
-
22
- ((exports) => {
23
- 'use strict';
24
-
25
- exports.runPageLabelsTest = () => {
26
- const main = async () => {
27
- const inputPath = '../TestFiles/';
28
- const outputPath = inputPath + 'Output/';
29
- const outputFile = outputPath + 'newsletter_with_pagelabels.pdf';
30
-
31
- try {
32
- //-----------------------------------------------------------
33
- // Example 1: Add page labels to an existing or newly created PDF
34
- // document.
35
- //-----------------------------------------------------------
36
- {
37
- const doc = await PDFNet.PDFDoc.createFromFilePath(inputPath + 'newsletter.pdf');
38
- doc.initSecurityHandler();
39
-
40
- // Create a page labeling scheme that starts with the first page in
41
- // the document (page 1) and is using uppercase roman numbering
42
- // style.
43
- const L1 = await PDFNet.PageLabel.create(doc, PDFNet.PageLabel.Style.e_roman_uppercase, 'My Prefix ', 1);
44
- doc.setPageLabel(1, L1);
45
-
46
- // Create a page labeling scheme that starts with the fourth page in
47
- // the document and is using decimal Arabic numbering style.
48
- // Also the numeric portion of the first label should start with number
49
- // 4 (otherwise the first label would be 'My Prefix 1').
50
- const L2 = await PDFNet.PageLabel.create(doc, PDFNet.PageLabel.Style.e_decimal, 'My Prefix ', 4);
51
- doc.setPageLabel(4, L2);
52
-
53
- // Create a page labeling scheme that starts with the seventh page in
54
- // the document and is using alphabetic numbering style. The numeric
55
- // portion of the first label should start with number 1.
56
- const L3 = await PDFNet.PageLabel.create(doc, PDFNet.PageLabel.Style.e_alphabetic_uppercase, 'My Prefix ', 1);
57
- doc.setPageLabel(7, L3);
58
-
59
- doc.save(outputFile, PDFNet.SDFDoc.SaveOptions.e_linearized);
60
- console.log('Done. Result saved in newsletter_with_pagelabels.pdf...');
61
- }
62
-
63
- //-----------------------------------------------------------
64
- // Example 2: Read page labels from an existing PDF document.
65
- //-----------------------------------------------------------
66
- {
67
- const doc = await PDFNet.PDFDoc.createFromFilePath(outputFile);
68
- doc.initSecurityHandler();
69
-
70
- const page_num = await doc.getPageCount();
71
- for (let i = 1; i <= page_num; ++i) {
72
- console.log('Page number: ' + i);
73
- const label = await doc.getPageLabel(i);
74
- if (await label.isValid()) {
75
- console.log(' Label: ' + await label.getLabelTitle(i));
76
- }
77
- else {
78
- console.log(' No Label.');
79
- }
80
- }
81
- }
82
-
83
- //-----------------------------------------------------------
84
- // Example 3: Modify page labels from an existing PDF document.
85
- //-----------------------------------------------------------
86
- {
87
- const doc = await PDFNet.PDFDoc.createFromFilePath(outputFile);
88
- doc.initSecurityHandler();
89
-
90
- // Remove the alphabetic labels from example 1.
91
- doc.removePageLabel(7);
92
-
93
- // Replace the Prefix in the decimal labels (from example 1).
94
- const label = await doc.getPageLabel(4);
95
- if (await label.isValid()) {
96
- await label.setPrefix('A');
97
- label.setStart(1);
98
- }
99
-
100
- // Add a new label
101
- const new_label = await PDFNet.PageLabel.create(doc, PDFNet.PageLabel.Style.e_decimal, 'B', 1);
102
- doc.setPageLabel(10, new_label); // starting from page 10.
103
-
104
- doc.save(outputPath + 'newsletter_with_pagelabels_modified.pdf', PDFNet.SDFDoc.SaveOptions.e_linearized);
105
- console.log('Done. Result saved in newsletter_with_pagelabels_modified.pdf...');
106
-
107
- const page_num = await doc.getPageCount();
108
- for (let i = 1; i <= page_num; ++i) {
109
- console.log('Page number: ' + i);
110
- const label = await doc.getPageLabel(i);
111
- if (await label.isValid()) {
112
- console.log(' Label: ' + await label.getLabelTitle(i));
113
- }
114
- else {
115
- console.log(' No Label.');
116
- }
117
- }
118
- }
119
-
120
- //-----------------------------------------------------------
121
- // Example 4: Delete all page labels in an existing PDF document.
122
- //-----------------------------------------------------------
123
- {
124
- const doc = await PDFNet.PDFDoc.createFromFilePath(outputFile);
125
- (await doc.getRoot()).eraseFromKey('PageLabels');
126
- }
127
-
128
- } catch (err) {
129
- console.log(err);
130
- }
131
- }
132
- PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error) {
133
- console.log('Error: ' + JSON.stringify(error));
134
- }).then(function(){ return PDFNet.shutdown(); });
135
- };
136
- exports.runPageLabelsTest();
137
- })(exports);
138
- // eslint-disable-next-line spaced-comment
1
+ //---------------------------------------------------------------------------------------
2
+ // Copyright (c) 2001-2024 by Apryse Software Inc. All Rights Reserved.
3
+ // Consult legal.txt regarding legal and license information.
4
+ //---------------------------------------------------------------------------------------
5
+
6
+ //-----------------------------------------------------------------------------------
7
+ // The sample illustrates how to work with PDF page labels.
8
+ //
9
+ // PDF page labels can be used to describe a page. This is used to
10
+ // allow for non-sequential page numbering or the addition of arbitrary
11
+ // labels for a page (such as the inclusion of Roman numerals at the
12
+ // beginning of a book). PDFNet PageLabel object can be used to specify
13
+ // the numbering style to use (for example, upper- or lower-case Roman,
14
+ // decimal, and so forth), the starting number for the first page,
15
+ // and an arbitrary prefix to be pre-appended to each number (for
16
+ // example, 'A-' to generate 'A-1', 'A-2', 'A-3', and so forth.)
17
+ //-----------------------------------------------------------------------------------
18
+
19
+ const { PDFNet } = require('@pdftron/pdfnet-node');
20
+ const PDFTronLicense = require('../LicenseKey/LicenseKey');
21
+
22
+ ((exports) => {
23
+ 'use strict';
24
+
25
+ exports.runPageLabelsTest = () => {
26
+ const main = async () => {
27
+ const inputPath = '../TestFiles/';
28
+ const outputPath = inputPath + 'Output/';
29
+ const outputFile = outputPath + 'newsletter_with_pagelabels.pdf';
30
+
31
+ try {
32
+ //-----------------------------------------------------------
33
+ // Example 1: Add page labels to an existing or newly created PDF
34
+ // document.
35
+ //-----------------------------------------------------------
36
+ {
37
+ const doc = await PDFNet.PDFDoc.createFromFilePath(inputPath + 'newsletter.pdf');
38
+ doc.initSecurityHandler();
39
+
40
+ // Create a page labeling scheme that starts with the first page in
41
+ // the document (page 1) and is using uppercase roman numbering
42
+ // style.
43
+ const L1 = await PDFNet.PageLabel.create(doc, PDFNet.PageLabel.Style.e_roman_uppercase, 'My Prefix ', 1);
44
+ doc.setPageLabel(1, L1);
45
+
46
+ // Create a page labeling scheme that starts with the fourth page in
47
+ // the document and is using decimal Arabic numbering style.
48
+ // Also the numeric portion of the first label should start with number
49
+ // 4 (otherwise the first label would be 'My Prefix 1').
50
+ const L2 = await PDFNet.PageLabel.create(doc, PDFNet.PageLabel.Style.e_decimal, 'My Prefix ', 4);
51
+ doc.setPageLabel(4, L2);
52
+
53
+ // Create a page labeling scheme that starts with the seventh page in
54
+ // the document and is using alphabetic numbering style. The numeric
55
+ // portion of the first label should start with number 1.
56
+ const L3 = await PDFNet.PageLabel.create(doc, PDFNet.PageLabel.Style.e_alphabetic_uppercase, 'My Prefix ', 1);
57
+ doc.setPageLabel(7, L3);
58
+
59
+ doc.save(outputFile, PDFNet.SDFDoc.SaveOptions.e_linearized);
60
+ console.log('Done. Result saved in newsletter_with_pagelabels.pdf...');
61
+ }
62
+
63
+ //-----------------------------------------------------------
64
+ // Example 2: Read page labels from an existing PDF document.
65
+ //-----------------------------------------------------------
66
+ {
67
+ const doc = await PDFNet.PDFDoc.createFromFilePath(outputFile);
68
+ doc.initSecurityHandler();
69
+
70
+ const page_num = await doc.getPageCount();
71
+ for (let i = 1; i <= page_num; ++i) {
72
+ console.log('Page number: ' + i);
73
+ const label = await doc.getPageLabel(i);
74
+ if (await label.isValid()) {
75
+ console.log(' Label: ' + await label.getLabelTitle(i));
76
+ }
77
+ else {
78
+ console.log(' No Label.');
79
+ }
80
+ }
81
+ }
82
+
83
+ //-----------------------------------------------------------
84
+ // Example 3: Modify page labels from an existing PDF document.
85
+ //-----------------------------------------------------------
86
+ {
87
+ const doc = await PDFNet.PDFDoc.createFromFilePath(outputFile);
88
+ doc.initSecurityHandler();
89
+
90
+ // Remove the alphabetic labels from example 1.
91
+ doc.removePageLabel(7);
92
+
93
+ // Replace the Prefix in the decimal labels (from example 1).
94
+ const label = await doc.getPageLabel(4);
95
+ if (await label.isValid()) {
96
+ await label.setPrefix('A');
97
+ label.setStart(1);
98
+ }
99
+
100
+ // Add a new label
101
+ const new_label = await PDFNet.PageLabel.create(doc, PDFNet.PageLabel.Style.e_decimal, 'B', 1);
102
+ doc.setPageLabel(10, new_label); // starting from page 10.
103
+
104
+ doc.save(outputPath + 'newsletter_with_pagelabels_modified.pdf', PDFNet.SDFDoc.SaveOptions.e_linearized);
105
+ console.log('Done. Result saved in newsletter_with_pagelabels_modified.pdf...');
106
+
107
+ const page_num = await doc.getPageCount();
108
+ for (let i = 1; i <= page_num; ++i) {
109
+ console.log('Page number: ' + i);
110
+ const label = await doc.getPageLabel(i);
111
+ if (await label.isValid()) {
112
+ console.log(' Label: ' + await label.getLabelTitle(i));
113
+ }
114
+ else {
115
+ console.log(' No Label.');
116
+ }
117
+ }
118
+ }
119
+
120
+ //-----------------------------------------------------------
121
+ // Example 4: Delete all page labels in an existing PDF document.
122
+ //-----------------------------------------------------------
123
+ {
124
+ const doc = await PDFNet.PDFDoc.createFromFilePath(outputFile);
125
+ (await doc.getRoot()).eraseFromKey('PageLabels');
126
+ }
127
+
128
+ } catch (err) {
129
+ console.log(err);
130
+ }
131
+ }
132
+ PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error) {
133
+ console.log('Error: ' + JSON.stringify(error));
134
+ }).then(function(){ return PDFNet.shutdown(); });
135
+ };
136
+ exports.runPageLabelsTest();
137
+ })(exports);
138
+ // eslint-disable-next-line spaced-comment
139
139
  //# sourceURL=PageLabelsTest.js