@pdftron/pdfnet-node-samples 9.5.0-4 → 9.5.0-4-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.
Files changed (145) hide show
  1. package/{samples/AddImageTest → AddImageTest}/AddImageTest.js +2 -2
  2. package/{samples/AdvancedImagingTest → AdvancedImagingTest}/AdvancedImagingTest.js +5 -5
  3. package/{samples/AnnotationTest → AnnotationTest}/AnnotationTest.js +1 -1
  4. package/BarcodeTest/BarcodeTest.js +120 -0
  5. package/{samples/BookmarkTest → BookmarkTest}/BookmarkTest.js +1 -1
  6. package/{samples/CAD2PDFTest → CAD2PDFTest}/CAD2PDFTest.js +5 -5
  7. package/{samples/ContentReplacerTest → ContentReplacerTest}/ContentReplacerTest.js +1 -1
  8. package/ConvertPrintTest/ConvertPrintTest.js +153 -0
  9. package/{samples/ConvertTest → ConvertTest}/ConvertTest.js +12 -79
  10. package/{samples/DataExtractionTest → DataExtractionTest}/DataExtractionTest.js +141 -10
  11. package/{samples/DigitalSignaturesTest → DigitalSignaturesTest}/DigitalSignaturesTest.js +126 -12
  12. package/DocumentCreationTest/DocumentCreationTest.js +409 -0
  13. package/{samples/ElementBuilderTest → ElementBuilderTest}/ElementBuilderTest.js +1 -1
  14. package/{samples/ElementEditTest → ElementEditTest}/ElementEditTest.js +1 -1
  15. package/{samples/ElementReaderAdvTest → ElementReaderAdvTest}/ElementReaderAdvTest.js +1 -1
  16. package/{samples/ElementReaderTest → ElementReaderTest}/ElementReaderTest.js +1 -1
  17. package/{samples/EncTest → EncTest}/EncTest.js +1 -1
  18. package/{samples/FDFTest → FDFTest}/FDFTest.js +1 -1
  19. package/FindReplaceTest/FindReplaceTest.js +56 -0
  20. package/{samples/HTML2PDFTest → HTML2PDFTest}/HTML2PDFTest.js +34 -35
  21. package/{samples/HighlightsTest → HighlightsTest}/HighlightsTest.js +1 -1
  22. package/{samples/ImageExtractTest → ImageExtractTest}/ImageExtractTest.js +3 -3
  23. package/{samples/ImpositionTest → ImpositionTest}/ImpositionTest.js +1 -1
  24. package/{samples/InteractiveFormsTest → InteractiveFormsTest}/InteractiveFormsTest.js +1 -1
  25. package/{samples/JBIG2Test → JBIG2Test}/JBIG2Test.js +7 -7
  26. package/{samples/LicenseKey → LicenseKey}/LicenseKey.js +3 -3
  27. package/{samples/LogicalStructureTest → LogicalStructureTest}/LogicalStructureTest.js +1 -1
  28. package/{samples/OCRTest → OCRTest}/OCRTest.js +6 -5
  29. package/{samples/OfficeTemplateTest → OfficeTemplateTest}/OfficeTemplateTest.js +2 -2
  30. package/{samples/OfficeToPDFTest → OfficeToPDFTest}/OfficeToPDFTest.js +1 -1
  31. package/{samples/OptimizerTest → OptimizerTest}/OptimizerTest.js +1 -1
  32. package/{samples/PDF2HtmlTest → PDF2HtmlTest}/PDF2HtmlTest.js +6 -6
  33. package/{samples/PDF2OfficeTest → PDF2OfficeTest}/PDF2OfficeTest.js +6 -6
  34. package/{samples/PDFATest → PDFATest}/PDFATest.js +1 -1
  35. package/{samples/PDFDocMemoryTest → PDFDocMemoryTest}/PDFDocMemoryTest.js +1 -1
  36. package/{samples/PDFDrawTest → PDFDrawTest}/PDFDrawTest.js +1 -1
  37. package/{samples/PDFLayersTest → PDFLayersTest}/PDFLayersTest.js +1 -1
  38. package/{samples/PDFPackageTest → PDFPackageTest}/PDFPackageTest.js +1 -1
  39. package/{samples/PDFPageTest → PDFPageTest}/PDFPageTest.js +1 -1
  40. package/{samples/PDFRedactTest → PDFRedactTest}/PDFRedactTest.js +1 -1
  41. package/PDFUATest/PDFUATest.js +88 -0
  42. package/{samples/PageLabelsTest → PageLabelsTest}/PageLabelsTest.js +1 -1
  43. package/{samples/PatternTest → PatternTest}/PatternTest.js +1 -1
  44. package/{samples/RectTest → RectTest}/RectTest.js +1 -1
  45. package/{samples/SDFTest → SDFTest}/SDFTest.js +3 -4
  46. package/{samples/StamperTest → StamperTest}/StamperTest.js +1 -1
  47. package/TestFiles/BusinessCardTemplate.pdf +0 -0
  48. package/TestFiles/Email.pdf +0 -0
  49. package/TestFiles/Fishermen.docx +0 -0
  50. package/TestFiles/Font_licenses.txt +140 -0
  51. package/TestFiles/Invoice.pdf +0 -0
  52. package/TestFiles/License.txt +1 -0
  53. package/TestFiles/Misc-Fixed.pfa +1166 -0
  54. package/TestFiles/NotoSans_with_hindi.ttf +0 -0
  55. package/TestFiles/Output/empty +1 -0
  56. package/TestFiles/SHA-2 Root USERTrust RSA CA Sectigo timestamping.crt +34 -0
  57. package/TestFiles/SYH_Letter.docx +0 -0
  58. package/TestFiles/Scientific_Publication.pdf +0 -0
  59. package/TestFiles/TigerText.pdf +0 -0
  60. package/TestFiles/US061222892-a.pdf +0 -0
  61. package/TestFiles/apryse.bmp +0 -0
  62. package/TestFiles/apryse.cer +0 -0
  63. package/TestFiles/apryse.pfx +0 -0
  64. package/TestFiles/autotag_input.pdf +0 -0
  65. package/TestFiles/butterfly.png +0 -0
  66. package/TestFiles/credit card numbers.pdf +0 -0
  67. package/TestFiles/dice.jpg +0 -0
  68. package/TestFiles/dice.u3d +0 -0
  69. package/TestFiles/doc_to_sign.pdf +0 -0
  70. package/TestFiles/factsheet_Arabic.docx +0 -0
  71. package/TestFiles/financial.pdf +0 -0
  72. package/TestFiles/find-replace-test.pdf +0 -0
  73. package/TestFiles/find-replace-test_(en_to_fr).xlf +88 -0
  74. package/TestFiles/fish.pdf +0 -0
  75. package/TestFiles/font.ttf +0 -0
  76. package/TestFiles/form1.pdf +246 -0
  77. package/TestFiles/form1_annots.xfdf +34 -0
  78. package/TestFiles/form1_data.fdf +4 -0
  79. package/TestFiles/form1_data.xfdf +140 -0
  80. package/TestFiles/formfields-scanned-withfields.pdf +0 -0
  81. package/TestFiles/formfields-scanned.pdf +0 -0
  82. package/TestFiles/formfields.pdf +0 -0
  83. package/TestFiles/grayscale.tif +0 -0
  84. package/TestFiles/hindi_sample_utf16le.txt +0 -0
  85. package/TestFiles/imagemask.dat +32 -0
  86. package/TestFiles/logo_red.png +0 -0
  87. package/TestFiles/lorem_ipsum.pdf +0 -0
  88. package/TestFiles/multipage.tif +0 -0
  89. package/TestFiles/my_stream.txt +2310 -0
  90. package/TestFiles/newsletter.pdf +0 -0
  91. package/TestFiles/newsletter.xod +0 -0
  92. package/TestFiles/numbered.pdf +0 -0
  93. package/TestFiles/op_blend_test.pdf +1497 -1
  94. package/TestFiles/palm.jp2 +0 -0
  95. package/TestFiles/paragraphs_and_tables.pdf +0 -0
  96. package/TestFiles/pdfnet.gif +0 -0
  97. package/TestFiles/pdftron_smart_substitution.plugin +0 -0
  98. package/TestFiles/peppers.jpg +0 -0
  99. package/TestFiles/signature.jpg +0 -0
  100. package/TestFiles/simple-emf.emf +0 -0
  101. package/TestFiles/simple-excel_2007.xlsx +0 -0
  102. package/TestFiles/simple-outlook.msg +0 -0
  103. package/TestFiles/simple-powerpoint_2007.pptx +0 -0
  104. package/TestFiles/simple-publisher.pub +0 -0
  105. package/TestFiles/simple-rtf.rtf +224 -0
  106. package/TestFiles/simple-text.txt +61 -0
  107. package/TestFiles/simple-visio.vsd +0 -0
  108. package/TestFiles/simple-webpage.html +731 -0
  109. package/TestFiles/simple-webpage.mht +6972 -0
  110. package/TestFiles/simple-webpage_files/colorschememapping.xml +2 -0
  111. package/TestFiles/simple-webpage_files/filelist.xml +14 -0
  112. package/TestFiles/simple-webpage_files/image001.gif +0 -0
  113. package/TestFiles/simple-webpage_files/image002.png +0 -0
  114. package/TestFiles/simple-webpage_files/image003.jpg +0 -0
  115. package/TestFiles/simple-webpage_files/image004.emz +0 -0
  116. package/TestFiles/simple-webpage_files/image005.gif +0 -0
  117. package/TestFiles/simple-webpage_files/image006.png +0 -0
  118. package/TestFiles/simple-webpage_files/image007.gif +0 -0
  119. package/TestFiles/simple-webpage_files/oledata.mso +0 -0
  120. package/TestFiles/simple-webpage_files/themedata.thmx +0 -0
  121. package/TestFiles/simple-word_2007.docx +0 -0
  122. package/TestFiles/simple-xps.xps +0 -0
  123. package/TestFiles/table.pdf +0 -0
  124. package/TestFiles/tagged.pdf +0 -0
  125. package/TestFiles/the_rime_of_the_ancient_mariner.docx +0 -0
  126. package/TestFiles/tiger.pdf +0 -0
  127. package/TestFiles/tiger.svg +378 -0
  128. package/TestFiles/waiver.pdf +0 -0
  129. package/TestFiles/waiver_withApprovalField.pdf +0 -0
  130. package/TestFiles/waiver_withApprovalField_certified.pdf +421 -1
  131. package/TestFiles/waiver_withApprovalField_certified_approved.pdf +465 -1
  132. package/{samples/TextExtractTest → TextExtractTest}/TextExtractTest.js +1 -1
  133. package/{samples/TextSearchTest → TextSearchTest}/TextSearchTest.js +2 -2
  134. package/TransPDFTest/TransPDFTest.js +68 -0
  135. package/{samples/U3DTest → U3DTest}/U3DTest.js +1 -1
  136. package/{samples/UndoRedoTest → UndoRedoTest}/UndoRedoTest.js +1 -1
  137. package/{samples/UnicodeWriteTest → UnicodeWriteTest}/UnicodeWriteTest.js +1 -1
  138. package/{samples/WebViewerConvertTest → WebViewerConvertTest}/WebViewerConvertTest.js +2 -2
  139. package/legal.txt +632 -0
  140. package/license.pdf +0 -0
  141. package/package.json +14 -41
  142. package/readme.md +32 -7
  143. package/{samples/runall.bat → runall.bat} +12 -12
  144. package/scripts/install.js +68 -0
  145. /package/{samples/runall.sh → runall.sh} +0 -0
@@ -0,0 +1,409 @@
1
+ //---------------------------------------------------------------------------------------
2
+ // Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved.
3
+ // Consult legal.txt regarding legal and license information.
4
+ //---------------------------------------------------------------------------------------
5
+
6
+ const { PDFNet } = require('@pdftron/pdfnet-node');
7
+ const PDFTronLicense = require('../LicenseKey/LicenseKey');
8
+
9
+ ((exports) => {
10
+ 'use strict';
11
+
12
+ exports.runDocumentCreationTest = async () => {
13
+ // Iterate over all text runs of the document and make every second run
14
+ // bold with smaller font size.
15
+ const modifyContentTree = async (node) => {
16
+ let bold = false;
17
+
18
+ const itr = await node.getContentNodeIterator();
19
+ while (await itr.hasNext()) {
20
+ const el = await itr.current();
21
+ itr.next();
22
+
23
+ const text_run = await el.asTextRun();
24
+ if (text_run !== null) {
25
+ if (bold) {
26
+ const styledElement = await text_run.getTextStyledElement();
27
+ styledElement.setBold(true);
28
+ styledElement.setFontSize(await styledElement.getFontSize() * 0.8);
29
+ }
30
+ bold = !bold;
31
+ continue;
32
+ }
33
+
34
+ const content_node = await el.asContentNode();
35
+ if (content_node !== null) {
36
+ await modifyContentTree(content_node);
37
+ continue;
38
+ }
39
+ }
40
+ };
41
+
42
+ const main = async () => {
43
+
44
+ const outputPath = '../TestFiles/Output/';
45
+ try {
46
+ const para_text =
47
+ "Lorem ipsum dolor " +
48
+ "sit amet, consectetur adipisicing elit, sed " +
49
+ "do eiusmod tempor incididunt ut labore " +
50
+ "et dolore magna aliqua. Ut enim ad " +
51
+ "minim veniam, quis nostrud exercitation " +
52
+ "ullamco laboris nisi ut aliquip ex ea " +
53
+ "commodo consequat. Duis aute irure " +
54
+ "dolor in reprehenderit in voluptate velit " +
55
+ "esse cillum dolore eu fugiat nulla pariatur. " +
56
+ "Excepteur sint occaecat cupidatat " +
57
+ "non proident, sunt in culpa qui officia " +
58
+ "deserunt mollit anim id est laborum.";
59
+
60
+ const flowdoc = await PDFNet.FlowDocument.create();
61
+ const para = await flowdoc.addParagraph();
62
+ const st_para = await para.getTextStyledElement();
63
+
64
+ st_para.setFontSize(24);
65
+ st_para.setTextColor(255, 0, 0);
66
+ para.addText('Start \tRed \tText\n');
67
+
68
+ para.addTabStop(150);
69
+ para.addTabStop(250);
70
+ st_para.setTextColor(0, 0, 255);
71
+ para.addText('Start \tBlue \tText\n');
72
+
73
+ let last_run = await para.addText('Start Green Text\n');
74
+
75
+ let start = true;
76
+ const para_itr = await para.getContentNodeIterator();
77
+ while (await para_itr.hasNext()) {
78
+ const el = await para_itr.current();
79
+ const run = await el.asTextRun();
80
+ if (run !== null) {
81
+ (await run.getTextStyledElement()).setFontSize(12);
82
+ if (start) {
83
+ // Restore red color.
84
+ start = false;
85
+ run.setText(await run.getText() + '(restored \tred \tcolor)\n');
86
+ (await run.getTextStyledElement()).setTextColor(255, 0, 0);
87
+ }
88
+ }
89
+ await para_itr.next();
90
+ }
91
+
92
+ const st_last = await last_run.getTextStyledElement();
93
+ st_last.setTextColor(0, 255, 0);
94
+ st_last.setItalic(true);
95
+ st_last.setFontSize(18);
96
+
97
+ (await para.getTextStyledElement()).setBold(true);
98
+ para.setBorder(0.2, 0, 127, 0);
99
+ st_last.setBold(false);
100
+
101
+ await flowdoc.addParagraphWithText('Simple list creation process. All elements are added in their natural order\n\n');
102
+
103
+ const list = await flowdoc.addList();
104
+ list.setNumberFormat(PDFNet.List.NumberFormat.e_upper_letter, ".", false);
105
+ list.setStartIndex(4);
106
+
107
+ const item = await list.addItem(); // creates "D."
108
+ item.addParagraphWithText('item 0[0]');
109
+ const px = await item.addParagraphWithText('item 0[1]');
110
+ const xx_para = await px.getTextStyledElement();
111
+ xx_para.setTextColor(255, 99, 71);
112
+ px.addText(' Some More Text!');
113
+
114
+ const item2 = await list.addItem(); // creates "E."
115
+ const item2List = await item2.addList();
116
+ item2List.setStartIndex(0);
117
+ item2List.setNumberFormat(PDFNet.List.NumberFormat.e_decimal, '', true);
118
+ (await item2List.addItem()).addParagraphWithText('item 1[0].0');
119
+ const pp = await (await item2List.addItem()).addParagraphWithText('item 1[0].1');
120
+ const sx_para = await pp.getTextStyledElement();
121
+ sx_para.setTextColor(0, 0, 255);
122
+ pp.addText(' Some More Text');
123
+ (await item2List.addItem()).addParagraphWithText('item 1[0].2');
124
+ const item2List1 = await (await item2List.addItem()).addList();
125
+ item2List1.setStartIndex(7);
126
+ item2List1.setNumberFormat(PDFNet.List.NumberFormat.e_upper_roman, ')', true);
127
+ (await item2List1.addItem()).addParagraphWithText('item 1[0].3.0');
128
+ (await item2List1.addItem()).addParagraphWithText('item 1[0].3.1');
129
+
130
+ const extraItem = await item2List1.addItem();
131
+ extraItem.addParagraphWithText('item 1[0].3.2[0]');
132
+ extraItem.addParagraphWithText('item 1[0].3.2[1]');
133
+ let fourth = await extraItem.addList();
134
+ fourth.setNumberFormat(PDFNet.List.NumberFormat.e_decimal, '', true);
135
+ (await fourth.addItem()).addParagraphWithText('Fourth Level');
136
+
137
+ fourth = await (await item2List1.addItem()).addList();
138
+ fourth.setNumberFormat(PDFNet.List.NumberFormat.e_lower_letter, '', true);
139
+ (await fourth.addItem()).addParagraphWithText('Fourth Level (again)');
140
+
141
+ item2.addParagraphWithText('item 1[1]');
142
+ const item2List2 = await item2.addList();
143
+ item2List2.setStartIndex(10);
144
+ item2List2.setNumberFormat(PDFNet.List.NumberFormat.e_lower_roman, ".", false);
145
+ (await item2List2.addItem()).addParagraphWithText('item 1[2].0');
146
+ (await item2List2.addItem()).addParagraphWithText('item 1[2].1');
147
+ (await item2List2.addItem()).addParagraphWithText('item 1[2].2');
148
+
149
+ const item3 = await list.addItem(); // creates "F."
150
+ item3.addParagraphWithText('item 2');
151
+
152
+ const item4 = await list.addItem(); // creates "G."
153
+ item4.addParagraphWithText('item 3');
154
+
155
+ const item5 = await list.addItem(); // creates "H."
156
+ item5.addParagraphWithText('item 4');
157
+
158
+ const body_itr = await (await flowdoc.getBody()).getContentNodeIterator();
159
+ while (await body_itr.hasNext()) {
160
+ const el = await body_itr.current();
161
+
162
+ const list = await el.asList();
163
+ if (list !== null && (await list.getIndentationLevel()) === 1) {
164
+ const p = await (await list.addItem()).addParagraphWithText('Item added during iteration');
165
+ const ps = await p.getTextStyledElement();
166
+ ps.setTextColor(0, 127, 0);
167
+ }
168
+
169
+ const list_item = await el.asListItem();
170
+ if (list_item !== null && (await list_item.getIndentationLevel()) === 2) {
171
+ const p = await list_item.addParagraphWithText('* Paragraph added during iteration');
172
+ const ps = await p.getTextStyledElement();
173
+ ps.setTextColor(0, 0, 255);
174
+ }
175
+ await body_itr.next();
176
+ }
177
+
178
+ flowdoc.addParagraphWithText('\f'); // page break
179
+
180
+ flowdoc.addParagraphWithText(
181
+ 'Nonlinear list creation flow. Items are added randomly.' +
182
+ ' List body separated by a paragraph, does not belong to the list\n\n'
183
+ );
184
+
185
+ const list2 = await flowdoc.addList();
186
+ list2.setNumberFormat(PDFNet.List.NumberFormat.e_upper_letter, ".", false);
187
+ list2.setStartIndex(4);
188
+
189
+ const item6 = await list2.addItem(); // creates "D."
190
+ item6.addParagraphWithText('item 0[0]');
191
+ const px2 = await item6.addParagraphWithText('item 0[1]');
192
+ const xx_para2 = await px2.getTextStyledElement();
193
+ xx_para2.setTextColor(255, 99, 71);
194
+ px2.addText(' Some More Text!');
195
+ item6.addParagraphWithText('item 0[2]');
196
+ const px3 = await item6.addParagraphWithText('item 0[3]');
197
+ item6.addParagraphWithText('item 0[4]');
198
+ const xx_para3 = await px3.getTextStyledElement();
199
+ xx_para3.setTextColor(255, 99, 71);
200
+
201
+ const item7 = await list2.addItem(); // creates "E."
202
+ const item7List = await item7.addList();
203
+ item7List.setStartIndex(0);
204
+ item7List.setNumberFormat(PDFNet.List.NumberFormat.e_decimal, '', true);
205
+ (await item7List.addItem()).addParagraphWithText('item 1[0].0');
206
+ const pp2 = await (await item7List.addItem()).addParagraphWithText('item 1[0].1');
207
+ const sx_para2 = await pp2.getTextStyledElement();
208
+ sx_para2.setTextColor(0, 0, 255);
209
+ pp2.addText(' Some More Text');
210
+
211
+ const item8 = await list2.addItem(); // creates "F."
212
+ item8.addParagraphWithText('item 2');
213
+
214
+ (await item7List.addItem()).addParagraphWithText('item 1[0].2');
215
+
216
+ item7.addParagraphWithText('item 1[1]');
217
+ const item7List2 = await item7.addList();
218
+ item7List2.setStartIndex(10);
219
+ item7List2.setNumberFormat(PDFNet.List.NumberFormat.e_lower_roman, ".", false);
220
+ (await item7List2.addItem()).addParagraphWithText('item 1[2].0');
221
+ (await item7List2.addItem()).addParagraphWithText('item 1[2].1');
222
+ (await item7List2.addItem()).addParagraphWithText('item 1[2].2');
223
+
224
+ const item9 = await list2.addItem(); // creates "G."
225
+ item9.addParagraphWithText('item 3');
226
+
227
+ const item7List1 = await (await item7List.addItem()).addList();
228
+ item7List1.setStartIndex(7);
229
+ item7List1.setNumberFormat(PDFNet.List.NumberFormat.e_upper_roman, ')', true);
230
+ (await item7List1.addItem()).addParagraphWithText('item 1[0].3.0');
231
+
232
+ flowdoc.addParagraphWithText(
233
+ '---------------------------------- splitting paragraph ----------------------------------'
234
+ );
235
+
236
+ item7List1.continueList();
237
+
238
+ (await item7List1.addItem()).addParagraphWithText('item 1[0].3.1 (continued)');
239
+ const extraItem2 = await item7List1.addItem();
240
+ extraItem2.addParagraphWithText('item 1[0].3.2[0]');
241
+ extraItem2.addParagraphWithText('item 1[0].3.2[1]');
242
+ let fourth2 = await extraItem2.addList();
243
+ fourth2.setNumberFormat(PDFNet.List.NumberFormat.e_decimal, '', true);
244
+ (await fourth2.addItem()).addParagraphWithText('FOURTH LEVEL');
245
+
246
+ const item10 = await list2.addItem(); // creates "H."
247
+ item10.addParagraphWithText('item 4 (continued)');
248
+
249
+ flowdoc.addParagraphWithText(' ');
250
+
251
+ flowdoc.setDefaultMargins(72.0, 72.0, 144.0, 228.0);
252
+ flowdoc.setDefaultPageSize(650, 750);
253
+ flowdoc.addParagraphWithText(para_text);
254
+
255
+ const clr1 = [50, 50, 199];
256
+ const clr2 = [30, 199, 30];
257
+
258
+ for (let i = 0; i < 50; i++) {
259
+ const para = await flowdoc.addParagraph();
260
+ const style = await para.getTextStyledElement();
261
+ const point_size = (17 * i * i * i) % 13 + 5;
262
+ if (i % 2 === 0) {
263
+ style.setItalic(true);
264
+ style.setTextColor(clr1[0], clr1[1], clr1[2]);
265
+ style.setBackgroundColor(200, 200, 200);
266
+ para.setSpaceBefore(20);
267
+ para.setStartIndent(20);
268
+ para.setJustificationMode(PDFNet.Paragraph.TextJustification.e_text_justify_left);
269
+ } else {
270
+ style.setTextColor(clr2[0], clr2[1], clr2[2]);
271
+ para.setSpaceBefore(50);
272
+ para.setEndIndent(20);
273
+ para.setJustificationMode(PDFNet.Paragraph.TextJustification.e_text_justify_right);
274
+ }
275
+
276
+ para.addText(para_text);
277
+ para.addText(' ' + para_text);
278
+ style.setFontSize(point_size);
279
+ }
280
+
281
+ // Table creation
282
+ const new_table = await flowdoc.addTable();
283
+ new_table.setDefaultColumnWidth(100);
284
+ new_table.setDefaultRowHeight(15);
285
+
286
+ for (let i = 0; i < 4; i++) {
287
+ const row = await new_table.addTableRow();
288
+ row.setRowHeight(await new_table.getDefaultRowHeight() + i * 5);
289
+ for (let j = 0; j < 5; j++) {
290
+ const cell = await row.addTableCell();
291
+ cell.setBorder(0.5, 255, 0, 0);
292
+
293
+ if (i === 3) {
294
+ if (j % 2 !== 0) {
295
+ cell.setVerticalAlignment(
296
+ PDFNet.TableCell.AlignmentVertical.e_alignment_center);
297
+ } else {
298
+ cell.setVerticalAlignment(
299
+ PDFNet.TableCell.AlignmentVertical.e_alignment_bottom);
300
+ }
301
+ }
302
+
303
+ if (i === 3 && j === 4) {
304
+ const para_title = await cell.addParagraphWithText('Table title');
305
+ para_title.setJustificationMode(
306
+ PDFNet.Paragraph.TextJustification.e_text_justify_center);
307
+
308
+ const nested_table = await cell.addTable();
309
+ nested_table.setDefaultColumnWidth(33);
310
+ nested_table.setDefaultRowHeight(5);
311
+ nested_table.setBorder(0.5, 0, 0, 0);
312
+
313
+ for (let nested_row_index = 0; nested_row_index < 3; nested_row_index++) {
314
+ const nested_row = await nested_table.addTableRow();
315
+ for (let nested_column_index = 0; nested_column_index < 3; nested_column_index++) {
316
+ const para_str = `${nested_row_index}/${nested_column_index}`;
317
+ const nested_cell = await nested_row.addTableCell();
318
+ nested_cell.setBackgroundColor(200, 200, 255);
319
+ nested_cell.setBorder(0.1, 0, 255, 0);
320
+
321
+ const new_para = await nested_cell.addParagraphWithText(para_str);
322
+ new_para.setJustificationMode(
323
+ PDFNet.Paragraph.TextJustification.e_text_justify_right);
324
+ }
325
+ }
326
+ } else if (i === 2 && j === 2) {
327
+ const new_para = await cell.addParagraphWithText(`Cell ${j} x ${i}\n`);
328
+ new_para.addText('to be bold text 1\n');
329
+ new_para.addText('still normal text\n');
330
+ new_para.addText('to be bold text 2');
331
+ cell.addParagraphWithText('Second Paragraph');
332
+ } else {
333
+ cell.addParagraphWithText(`Cell ${j} x ${i}`);
334
+ }
335
+ }
336
+ }
337
+
338
+ // Walk the content tree and modify some text runs.
339
+ await modifyContentTree(await flowdoc.getBody());
340
+
341
+ // Merge cells
342
+ const merged_cell = await (await new_table.getTableCell(2, 0)).mergeCellsRight(1);
343
+ merged_cell.setHorizontalAlignment(PDFNet.TableCell.AlignmentHorizontal.e_alignment_middle);
344
+
345
+ (await (await new_table.getTableCell(0, 0)).mergeCellsDown(1)).setVerticalAlignment(
346
+ PDFNet.TableCell.AlignmentVertical.e_alignment_center
347
+ );
348
+
349
+ // Walk over the table and change the first cell in each row.
350
+ let row_idx = 0;
351
+ const clr_row1 = [175, 240, 240];
352
+ const clr_row2 = [250, 250, 175];
353
+
354
+ const table_itr = await new_table.getContentNodeIterator();
355
+ while (await table_itr.hasNext()) {
356
+ const row = await (await table_itr.current()).asTableRow();
357
+ if (row !== null) {
358
+ const row_itr = await row.getContentNodeIterator();
359
+ while (await row_itr.hasNext()) {
360
+ const cell = await (await row_itr.current()).asTableCell();
361
+ if (cell !== null) {
362
+ if (row_idx % 2 !== 0) {
363
+ cell.setBackgroundColor(clr_row1[0], clr_row1[1], clr_row1[2]);
364
+ } else {
365
+ cell.setBackgroundColor(clr_row2[0], clr_row2[1], clr_row2[2]);
366
+ }
367
+
368
+ const cell_itr = await cell.getContentNodeIterator();
369
+ while (await cell_itr.hasNext()) {
370
+ const element = await cell_itr.current();
371
+ const para = await element.asParagraph();
372
+ if (para !== null) {
373
+ const st = await para.getTextStyledElement();
374
+ st.setTextColor(255, 0, 0);
375
+ st.setFontSize(12);
376
+ } else {
377
+ const nested_table = await element.asTable();
378
+ if (nested_table !== null) {
379
+ const nested_cell = await nested_table.getTableCell(1, 1);
380
+ nested_cell.setBackgroundColor(255, 127, 127);
381
+ }
382
+ }
383
+ await cell_itr.next();
384
+ }
385
+ }
386
+ await row_itr.next();
387
+ }
388
+ }
389
+
390
+ row_idx += 1;
391
+ await table_itr.next();
392
+ }
393
+
394
+ const my_pdf = await flowdoc.paginateToPDF();
395
+ my_pdf.save(outputPath + "created_doc.pdf", PDFNet.SDFDoc.SaveOptions.e_linearized);
396
+ console.log('Done.');
397
+ } catch (err) {
398
+ console.log(err);
399
+ }
400
+ };
401
+
402
+ PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) {
403
+ console.log('Error: ' + JSON.stringify(error));
404
+ }).then(function () { return PDFNet.shutdown(); });
405
+ };
406
+ exports.runDocumentCreationTest();
407
+ })(exports);
408
+ // eslint-disable-next-line spaced-comment
409
+ //# sourceURL=DocumentCreationTest.js
@@ -1,5 +1,5 @@
1
1
  //---------------------------------------------------------------------------------------
2
- // Copyright (c) 2001-2023 by PDFTron Systems Inc. All Rights Reserved.
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
 
@@ -1,5 +1,5 @@
1
1
  //---------------------------------------------------------------------------------------
2
- // Copyright (c) 2001-2023 by PDFTron Systems Inc. All Rights Reserved.
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
 
@@ -1,5 +1,5 @@
1
1
  //---------------------------------------------------------------------------------------
2
- // Copyright (c) 2001-2023 by PDFTron Systems Inc. All Rights Reserved.
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
 
@@ -1,5 +1,5 @@
1
1
  //---------------------------------------------------------------------------------------
2
- // Copyright (c) 2001-2023 by PDFTron Systems Inc. All Rights Reserved.
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
 
@@ -1,5 +1,5 @@
1
1
  //---------------------------------------------------------------------------------------
2
- // Copyright (c) 2001-2023 by PDFTron Systems Inc. All Rights Reserved.
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
 
@@ -1,5 +1,5 @@
1
1
  //---------------------------------------------------------------------------------------
2
- // Copyright (c) 2001-2023 by PDFTron Systems Inc. All Rights Reserved.
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
 
@@ -0,0 +1,56 @@
1
+ //---------------------------------------------------------------------------------------
2
+ // Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved.
3
+ // Consult legal.txt regarding legal and license information.
4
+ //---------------------------------------------------------------------------------------
5
+
6
+ //---------------------------------------------------------------------------------------
7
+ // The following sample illustrates how to find and replace text in a document
8
+ //---------------------------------------------------------------------------------------
9
+
10
+ const { PDFNet } = require('@pdftron/pdfnet-node');
11
+ const PDFTronLicense = require('../LicenseKey/LicenseKey');
12
+
13
+ ((exports) => {
14
+
15
+ exports.runFindReplace = () => {
16
+
17
+ const main = async () => {
18
+ // Relative path to the folder containing test files.
19
+ const inputPath = '../TestFiles/';
20
+ const outputPath = inputPath + 'Output/';
21
+
22
+ try {
23
+ // start stack-based deallocation with startDeallocateStack. Later on when endDeallocateStack is called,
24
+ // all objects in memory that were initialized since the most recent startDeallocateStack call will be
25
+ // cleaned up. Doing this makes sure that memory growth does not get too high.
26
+ await PDFNet.startDeallocateStack();
27
+
28
+ // Open a PDF document to edit
29
+ const doc = await PDFNet.PDFDoc.createFromFilePath(inputPath + 'find-replace-test.pdf');
30
+
31
+ const options = await PDFNet.FindReplace.createFindReplaceOptions();
32
+
33
+ // Set some find/replace options
34
+ options.setWholeWords(true);
35
+ options.setMatchCase(true);
36
+ options.setMatchMode(PDFNet.FindReplace.FindReplaceOptions.MatchType.e_exact);
37
+ options.setReflowMode(PDFNet.FindReplace.FindReplaceOptions.ReflowType.e_para);
38
+ options.setAlignment(PDFNet.FindReplace.FindReplaceOptions.HorizAlignment.e_left);
39
+
40
+ // Perform a Find/Replace finding "the" with "THE INCREDIBLE"
41
+ await PDFNet.FindReplace.findReplaceText(doc, "the", "THE INCREDIBLE", options);
42
+
43
+ // Save the edited PDF
44
+ await doc.save(outputPath + 'find-replace-test-replaced.pdf', PDFNet.SDFDoc.SaveOptions.e_linearized);
45
+
46
+ await PDFNet.endDeallocateStack();
47
+ } catch (err) {
48
+ console.log(err.stack);
49
+ }
50
+ };
51
+ PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) { console.log('Error: ' + JSON.stringify(error)); }).then(function () { return PDFNet.shutdown(); });
52
+ };
53
+ exports.runFindReplace();
54
+ })(exports);
55
+ // eslint-disable-next-line spaced-comment
56
+ //# sourceURL=FindReplaceTest.js
@@ -1,5 +1,5 @@
1
1
  //---------------------------------------------------------------------------------------
2
- // Copyright (c) 2001-2023 by PDFTron Systems Inc. All Rights Reserved.
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 http://www.pdftron.com/pdfnet/downloads.html.
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.
@@ -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://www.pdftron.com';
32
+ const host = 'https://docs.apryse.com';
33
33
  const page0 = '/';
34
- const page1 = '/support';
35
- const page2 = '/blog';
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('../lib/');
40
+ await PDFNet.HTML2PDF.setModulePath('../../lib/');
40
41
 
41
42
  if(!(await PDFNet.HTML2PDF.isModuleAvailable())) {
42
- console.log('Unable to run HTML2PDFTest: PDFTron SDK HTML2PDF module not available.');
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.pdftron.com/. If you have already downloaded this');
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
- if (await html2pdf.convert(doc)) {
62
- doc.save(outputPath.concat('_01.pdf'), PDFNet.SDFDoc.SaveOptions.e_linearized);
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
- if (await html2pdf.convert(doc)) {
88
- doc.save(outputPath.concat('_02.pdf'), PDFNet.SDFDoc.SaveOptions.e_linearized);
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
- const is_conversion_0_successful = await converter.convert(doc);
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
- const is_conversion_1_successful = await converter.convert(doc);
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
- const is_conversion_2_successful = await another_converter.convert(doc);
127
-
128
- if(is_conversion_0_successful && is_conversion_1_successful && is_conversion_2_successful) {
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
- if (await html2pdf.convert(doc)) {
148
- doc.save(outputPath.concat('_04.pdf'), PDFNet.SDFDoc.SaveOptions.e_linearized);
149
- } else {
150
- console.log('Conversion failed. HTTP Code: ' + await html2pdf.getHttpErrorCode());
151
- console.log(await html2pdf.getLog());
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,5 +1,5 @@
1
1
  //---------------------------------------------------------------------------------------
2
- // Copyright (c) 2001-2023 by PDFTron Systems Inc. All Rights Reserved.
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