@pdftron/pdfnet-node-samples 10.9.0 → 10.10.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 (135) hide show
  1. package/{samples/AddImageTest → AddImageTest}/AddImageTest.js +115 -115
  2. package/{samples/AdvancedImagingTest → AdvancedImagingTest}/AdvancedImagingTest.js +78 -78
  3. package/{samples/AnnotationTest → AnnotationTest}/AnnotationTest.js +641 -641
  4. package/{samples/BookmarkTest → BookmarkTest}/BookmarkTest.js +219 -219
  5. package/{samples/CAD2PDFTest → CAD2PDFTest}/CAD2PDFTest.js +79 -79
  6. package/{samples/ContentReplacerTest → ContentReplacerTest}/ContentReplacerTest.js +75 -75
  7. package/{samples/ConvertPrintTest → ConvertPrintTest}/ConvertPrintTest.js +153 -153
  8. package/{samples/ConvertTest → ConvertTest}/ConvertTest.js +203 -203
  9. package/{samples/DataExtractionTest → DataExtractionTest}/DataExtractionTest.js +214 -214
  10. package/{samples/DigitalSignaturesTest → DigitalSignaturesTest}/DigitalSignaturesTest.js +622 -527
  11. package/{samples/DocumentCreationTest → DocumentCreationTest}/DocumentCreationTest.js +409 -409
  12. package/{samples/ElementBuilderTest → ElementBuilderTest}/ElementBuilderTest.js +513 -513
  13. package/{samples/ElementEditTest → ElementEditTest}/ElementEditTest.js +110 -110
  14. package/{samples/ElementReaderAdvTest → ElementReaderAdvTest}/ElementReaderAdvTest.js +305 -305
  15. package/{samples/ElementReaderTest → ElementReaderTest}/ElementReaderTest.js +77 -77
  16. package/{samples/EncTest → EncTest}/EncTest.js +175 -175
  17. package/{samples/FDFTest → FDFTest}/FDFTest.js +218 -218
  18. package/{samples/HTML2PDFTest → HTML2PDFTest}/HTML2PDFTest.js +164 -164
  19. package/{samples/HighlightsTest → HighlightsTest}/HighlightsTest.js +97 -97
  20. package/{samples/ImageExtractTest → ImageExtractTest}/ImageExtractTest.js +129 -129
  21. package/{samples/ImpositionTest → ImpositionTest}/ImpositionTest.js +86 -86
  22. package/{samples/InteractiveFormsTest → InteractiveFormsTest}/InteractiveFormsTest.js +381 -381
  23. package/{samples/JBIG2Test → JBIG2Test}/JBIG2Test.js +88 -88
  24. package/{samples/LicenseKey → LicenseKey}/LicenseKey.js +11 -11
  25. package/{samples/LogicalStructureTest → LogicalStructureTest}/LogicalStructureTest.js +250 -250
  26. package/{samples/OCRTest → OCRTest}/OCRTest.js +235 -235
  27. package/{samples/OfficeTemplateTest → OfficeTemplateTest}/OfficeTemplateTest.js +79 -79
  28. package/{samples/OfficeToPDFTest → OfficeToPDFTest}/OfficeToPDFTest.js +125 -125
  29. package/{samples/OptimizerTest → OptimizerTest}/OptimizerTest.js +191 -191
  30. package/{samples/PDF2HtmlTest → PDF2HtmlTest}/PDF2HtmlTest.js +123 -123
  31. package/{samples/PDF2OfficeTest → PDF2OfficeTest}/PDF2OfficeTest.js +158 -158
  32. package/{samples/PDFATest → PDFATest}/PDFATest.js +85 -85
  33. package/{samples/PDFDocMemoryTest → PDFDocMemoryTest}/PDFDocMemoryTest.js +84 -84
  34. package/{samples/PDFDrawTest → PDFDrawTest}/PDFDrawTest.js +305 -305
  35. package/{samples/PDFLayersTest → PDFLayersTest}/PDFLayersTest.js +294 -294
  36. package/{samples/PDFPackageTest → PDFPackageTest}/PDFPackageTest.js +111 -111
  37. package/{samples/PDFPageTest → PDFPageTest}/PDFPageTest.js +189 -189
  38. package/{samples/PDFRedactTest → PDFRedactTest}/PDFRedactTest.js +74 -74
  39. package/{samples/PageLabelsTest → PageLabelsTest}/PageLabelsTest.js +138 -138
  40. package/{samples/PatternTest → PatternTest}/PatternTest.js +226 -226
  41. package/{samples/RectTest → RectTest}/RectTest.js +40 -40
  42. package/{samples/SDFTest → SDFTest}/SDFTest.js +87 -87
  43. package/{samples/StamperTest → StamperTest}/StamperTest.js +255 -255
  44. package/{samples/TestFiles → TestFiles}/Misc-Fixed.pfa +1166 -1166
  45. package/{samples/TestFiles → TestFiles}/SHA-2 Root USERTrust RSA CA Sectigo timestamping.crt +34 -34
  46. package/{samples/TestFiles → TestFiles}/form1_annots.xfdf +33 -33
  47. package/{samples/TestFiles → TestFiles}/form1_data.xfdf +139 -139
  48. package/{samples/TestFiles → TestFiles}/my_stream.txt +2310 -2310
  49. package/{samples/TestFiles → TestFiles}/tiger.svg +378 -378
  50. package/{samples/TextExtractTest → TextExtractTest}/TextExtractTest.js +286 -286
  51. package/{samples/TextSearchTest → TextSearchTest}/TextSearchTest.js +121 -121
  52. package/{samples/U3DTest → U3DTest}/U3DTest.js +104 -104
  53. package/{samples/UndoRedoTest → UndoRedoTest}/UndoRedoTest.js +101 -101
  54. package/{samples/UnicodeWriteTest → UnicodeWriteTest}/UnicodeWriteTest.js +173 -173
  55. package/{samples/WebViewerConvertTest → WebViewerConvertTest}/WebViewerConvertTest.js +135 -135
  56. package/legal.txt +632 -0
  57. package/license.pdf +0 -0
  58. package/package.json +20 -21
  59. package/readme.md +38 -13
  60. package/{samples/runall.bat → runall.bat} +12 -12
  61. package/{samples/runall.sh → runall.sh} +15 -15
  62. /package/{samples/TestFiles → TestFiles}/BusinessCardTemplate.pdf +0 -0
  63. /package/{samples/TestFiles → TestFiles}/Fishermen.docx +0 -0
  64. /package/{samples/TestFiles → TestFiles}/Font_licenses.txt +0 -0
  65. /package/{samples/TestFiles → TestFiles}/GlobalSignRootForTST.cer +0 -0
  66. /package/{samples/TestFiles → TestFiles}/License.txt +0 -0
  67. /package/{samples/TestFiles → TestFiles}/NotoSans_with_hindi.ttf +0 -0
  68. /package/{samples/TestFiles → TestFiles}/Output/empty +0 -0
  69. /package/{samples/TestFiles → TestFiles}/SYH_Letter.docx +0 -0
  70. /package/{samples/TestFiles → TestFiles}/TigerText.pdf +0 -0
  71. /package/{samples/TestFiles → TestFiles}/US061222892-a.pdf +0 -0
  72. /package/{samples/TestFiles → TestFiles}/butterfly.png +0 -0
  73. /package/{samples/TestFiles → TestFiles}/credit card numbers.pdf +0 -0
  74. /package/{samples/TestFiles → TestFiles}/dice.jpg +0 -0
  75. /package/{samples/TestFiles → TestFiles}/dice.u3d +0 -0
  76. /package/{samples/TestFiles → TestFiles}/doc_to_sign.pdf +0 -0
  77. /package/{samples/TestFiles → TestFiles}/factsheet_Arabic.docx +0 -0
  78. /package/{samples/TestFiles → TestFiles}/financial.pdf +0 -0
  79. /package/{samples/TestFiles → TestFiles}/fish.pdf +0 -0
  80. /package/{samples/TestFiles → TestFiles}/font.ttf +0 -0
  81. /package/{samples/TestFiles → TestFiles}/form1.pdf +0 -0
  82. /package/{samples/TestFiles → TestFiles}/form1_data.fdf +0 -0
  83. /package/{samples/TestFiles → TestFiles}/formfields-scanned-withfields.pdf +0 -0
  84. /package/{samples/TestFiles → TestFiles}/formfields-scanned.pdf +0 -0
  85. /package/{samples/TestFiles → TestFiles}/formfields.pdf +0 -0
  86. /package/{samples/TestFiles → TestFiles}/grayscale.tif +0 -0
  87. /package/{samples/TestFiles → TestFiles}/hindi_sample_utf16le.txt +0 -0
  88. /package/{samples/TestFiles → TestFiles}/imagemask.dat +0 -0
  89. /package/{samples/TestFiles → TestFiles}/logo_red.png +0 -0
  90. /package/{samples/TestFiles → TestFiles}/lorem_ipsum.pdf +0 -0
  91. /package/{samples/TestFiles → TestFiles}/multipage.tif +0 -0
  92. /package/{samples/TestFiles → TestFiles}/newsletter.pdf +0 -0
  93. /package/{samples/TestFiles → TestFiles}/newsletter.xod +0 -0
  94. /package/{samples/TestFiles → TestFiles}/numbered.pdf +0 -0
  95. /package/{samples/TestFiles → TestFiles}/op_blend_test.pdf +0 -0
  96. /package/{samples/TestFiles → TestFiles}/palm.jp2 +0 -0
  97. /package/{samples/TestFiles → TestFiles}/paragraphs_and_tables.pdf +0 -0
  98. /package/{samples/TestFiles → TestFiles}/pdfnet.gif +0 -0
  99. /package/{samples/TestFiles → TestFiles}/pdftron.bmp +0 -0
  100. /package/{samples/TestFiles → TestFiles}/pdftron.cer +0 -0
  101. /package/{samples/TestFiles → TestFiles}/pdftron.pfx +0 -0
  102. /package/{samples/TestFiles → TestFiles}/pdftron_smart_substitution.plugin +0 -0
  103. /package/{samples/TestFiles → TestFiles}/peppers.jpg +0 -0
  104. /package/{samples/TestFiles → TestFiles}/signature.jpg +0 -0
  105. /package/{samples/TestFiles → TestFiles}/simple-emf.emf +0 -0
  106. /package/{samples/TestFiles → TestFiles}/simple-excel_2007.xlsx +0 -0
  107. /package/{samples/TestFiles → TestFiles}/simple-outlook.msg +0 -0
  108. /package/{samples/TestFiles → TestFiles}/simple-powerpoint_2007.pptx +0 -0
  109. /package/{samples/TestFiles → TestFiles}/simple-publisher.pub +0 -0
  110. /package/{samples/TestFiles → TestFiles}/simple-rtf.rtf +0 -0
  111. /package/{samples/TestFiles → TestFiles}/simple-text.txt +0 -0
  112. /package/{samples/TestFiles → TestFiles}/simple-visio.vsd +0 -0
  113. /package/{samples/TestFiles → TestFiles}/simple-webpage.html +0 -0
  114. /package/{samples/TestFiles → TestFiles}/simple-webpage.mht +0 -0
  115. /package/{samples/TestFiles → TestFiles}/simple-webpage_files/colorschememapping.xml +0 -0
  116. /package/{samples/TestFiles → TestFiles}/simple-webpage_files/filelist.xml +0 -0
  117. /package/{samples/TestFiles → TestFiles}/simple-webpage_files/image001.gif +0 -0
  118. /package/{samples/TestFiles → TestFiles}/simple-webpage_files/image002.png +0 -0
  119. /package/{samples/TestFiles → TestFiles}/simple-webpage_files/image003.jpg +0 -0
  120. /package/{samples/TestFiles → TestFiles}/simple-webpage_files/image004.emz +0 -0
  121. /package/{samples/TestFiles → TestFiles}/simple-webpage_files/image005.gif +0 -0
  122. /package/{samples/TestFiles → TestFiles}/simple-webpage_files/image006.png +0 -0
  123. /package/{samples/TestFiles → TestFiles}/simple-webpage_files/image007.gif +0 -0
  124. /package/{samples/TestFiles → TestFiles}/simple-webpage_files/oledata.mso +0 -0
  125. /package/{samples/TestFiles → TestFiles}/simple-webpage_files/themedata.thmx +0 -0
  126. /package/{samples/TestFiles → TestFiles}/simple-word_2007.docx +0 -0
  127. /package/{samples/TestFiles → TestFiles}/simple-xps.xps +0 -0
  128. /package/{samples/TestFiles → TestFiles}/table.pdf +0 -0
  129. /package/{samples/TestFiles → TestFiles}/tagged.pdf +0 -0
  130. /package/{samples/TestFiles → TestFiles}/the_rime_of_the_ancient_mariner.docx +0 -0
  131. /package/{samples/TestFiles → TestFiles}/tiger.pdf +0 -0
  132. /package/{samples/TestFiles → TestFiles}/waiver.pdf +0 -0
  133. /package/{samples/TestFiles → TestFiles}/waiver_withApprovalField.pdf +0 -0
  134. /package/{samples/TestFiles → TestFiles}/waiver_withApprovalField_certified.pdf +0 -0
  135. /package/{samples/TestFiles → TestFiles}/waiver_withApprovalField_certified_approved.pdf +0 -0
@@ -1,409 +1,409 @@
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
- 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
+ //---------------------------------------------------------------------------------------
2
+ // Copyright (c) 2001-2024 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