@pdftron/pdfnet-node-samples 12.1.0 → 12.2.1-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ConvertPrintTest/ConvertPrintTest.js +40 -18
- package/DataExtractionTest/DataExtractionTest.js +14 -0
- package/DocumentCreationTest/DocumentCreationTest.js +551 -363
- package/LicenseKey/LicenseKey.js +1 -1
- package/OCRTest/OCRTest.js +53 -0
- package/PDF2OfficeTest/PDF2OfficeTest.js +23 -0
- package/legal.txt +3 -3
- package/package.json +3 -2
- package/readme.md +2 -2
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// It supports several input formats like docx, xlsx, rtf, txt, html, pub, emf, etc. For more details, visit
|
|
9
9
|
// https://docs.apryse.com/documentation/windows/guides/features/conversion/convert-other/
|
|
10
10
|
//
|
|
11
|
-
//
|
|
11
|
+
// It is possible that a document will require the PDFNet printer for conversion.
|
|
12
12
|
// The installing application must be run as administrator. The manifest for this sample
|
|
13
13
|
// specifies appropriate the UAC elevation.
|
|
14
14
|
//
|
|
@@ -37,7 +37,6 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
37
37
|
|
|
38
38
|
const testfiles = [
|
|
39
39
|
new Testfile('simple-word_2007.docx', 'docx2pdf.pdf'),
|
|
40
|
-
new Testfile('simple-powerpoint_2007.pptx', 'pptx2pdf.pdf'),
|
|
41
40
|
new Testfile('simple-excel_2007.xlsx', 'xlsx2pdf.pdf'),
|
|
42
41
|
new Testfile('simple-publisher.pub', 'pub2pdf.pdf'),
|
|
43
42
|
new Testfile('simple-text.txt', 'txt2pdf.pdf'),
|
|
@@ -88,37 +87,60 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
88
87
|
};
|
|
89
88
|
|
|
90
89
|
const convertToPdfFromFile = async () => {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
try {
|
|
95
|
-
// This will fail if not run as administrator. Harmless if PDFNet
|
|
96
|
-
// printer already installed
|
|
97
|
-
console.log('Installing printer (requires Windows platform and administrator)');
|
|
98
|
-
await PDFNet.Convert.printerInstall();
|
|
99
|
-
console.log('Installed printer ' + await PDFNet.Convert.printerGetPrinterName());
|
|
100
|
-
} catch (err) {
|
|
101
|
-
console.log('Unable to install printer');
|
|
90
|
+
try {
|
|
91
|
+
if (await PDFNet.Convert.printerIsInstalled('PDFTron PDFNet')) {
|
|
92
|
+
await PDFNet.Convert.printerSetPrinterName('PDFTron PDFNet');
|
|
102
93
|
}
|
|
103
|
-
|
|
94
|
+
} catch (err) {
|
|
95
|
+
console.log('Warning: Unable to determine if the printer is installed or unable to set name of printer to use.');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const default_printer_mode = await PDFNet.Convert.printerGetMode();
|
|
99
|
+
|
|
104
100
|
for (const testfile of testfiles) {
|
|
105
101
|
|
|
106
102
|
try {
|
|
107
103
|
const pdfdoc = await PDFNet.PDFDoc.create();
|
|
104
|
+
|
|
105
|
+
await PDFNet.Convert.printerSetMode(default_printer_mode);
|
|
106
|
+
|
|
108
107
|
await pdfdoc.initSecurityHandler();
|
|
109
108
|
const inputFile = inputPath + testfile.inputFile;
|
|
110
109
|
const outputFile = outputPath + testfile.outputFile;
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
|
|
111
|
+
let retryConvert = false;
|
|
112
|
+
try {
|
|
113
|
+
await PDFNet.Convert.toPdf(pdfdoc, inputFile);
|
|
114
|
+
await pdfdoc.save(outputFile, PDFNet.SDFDoc.SaveOptions.e_linearized);
|
|
115
|
+
} catch (err) {
|
|
116
|
+
if (!(await PDFNet.Convert.printerIsInstalled())) {
|
|
117
|
+
try {
|
|
118
|
+
// This will fail if not run as administrator. Harmless if PDFNet
|
|
119
|
+
// printer already installed
|
|
120
|
+
console.log('Installing printer (requires Windows platform and administrator)');
|
|
121
|
+
await PDFNet.Convert.printerInstall();
|
|
122
|
+
await PDFNet.Convert.printerSetPrinterName('PDFTron PDFNet');
|
|
123
|
+
console.log('Installed printer ' + await PDFNet.Convert.printerGetPrinterName());
|
|
124
|
+
} catch (installErr) {
|
|
125
|
+
console.log('Unable to install printer');
|
|
126
|
+
throw err; // original exception
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
await PDFNet.Convert.printerSetMode(PDFNet.Convert.PrinterMode.e_printer_only);
|
|
130
|
+
retryConvert = true;
|
|
131
|
+
}
|
|
132
|
+
if (retryConvert) {
|
|
133
|
+
await PDFNet.Convert.toPdf(pdfdoc, inputFile);
|
|
134
|
+
await pdfdoc.save(outputFile, PDFNet.SDFDoc.SaveOptions.e_linearized);
|
|
113
135
|
}
|
|
114
|
-
await PDFNet.Convert.toPdf(pdfdoc, inputFile);
|
|
115
|
-
await pdfdoc.save(outputFile, PDFNet.SDFDoc.SaveOptions.e_linearized);
|
|
116
136
|
console.log('Converted file: ' + testfile.inputFile + '\nto: ' + testfile.outputFile);
|
|
117
137
|
} catch (err) {
|
|
118
138
|
console.log('Unable to convert file ' + testfile.inputFile);
|
|
119
139
|
console.log(err);
|
|
120
140
|
}
|
|
121
141
|
}
|
|
142
|
+
|
|
143
|
+
await PDFNet.Convert.printerSetMode(default_printer_mode);
|
|
122
144
|
};
|
|
123
145
|
|
|
124
146
|
const convertSpecificFormats = async () => {
|
|
@@ -122,6 +122,20 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
122
122
|
fs.writeFileSync(outputFile, json);
|
|
123
123
|
|
|
124
124
|
console.log('Result saved in ' + outputFile);
|
|
125
|
+
|
|
126
|
+
///////////////////////////////////////////////////////
|
|
127
|
+
// Extract document structure as a Markdown file using the Paddle OCR engine.
|
|
128
|
+
// Note: unlike the default OCR engine, Paddle does not support automatic language
|
|
129
|
+
// detection, so the OCR language must be set explicitly (the default is English).
|
|
130
|
+
console.log('Extract document structure as a Markdown file using the Paddle OCR engine');
|
|
131
|
+
|
|
132
|
+
outputFile = outputPath + 'US061222892-a.md';
|
|
133
|
+
const mdOptions = new PDFNet.DataExtractionModule.DataExtractionOptions();
|
|
134
|
+
mdOptions.setLanguage('eng');
|
|
135
|
+
mdOptions.setPreferredOCREngine(PDFNet.DataExtractionModule.DataExtractionOptions.DataExtractionOCREngine.e_extract_ocr_paddle);
|
|
136
|
+
await PDFNet.DataExtractionModule.extractToMarkdown(inputPath + 'US061222892-a.pdf', outputFile, mdOptions);
|
|
137
|
+
|
|
138
|
+
console.log('Result saved in ' + outputFile);
|
|
125
139
|
} catch (err) {
|
|
126
140
|
console.log(err);
|
|
127
141
|
}
|
|
@@ -6,396 +6,584 @@
|
|
|
6
6
|
const { PDFNet } = require('@pdftron/pdfnet-node');
|
|
7
7
|
const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
8
8
|
|
|
9
|
+
//---------------------------------------------------------------------------------------
|
|
10
|
+
// The following sample illustrates how to use the PDFNet.FlowDocument API to create
|
|
11
|
+
// documents from scratch. Instead of positioning every element on a page, the content is
|
|
12
|
+
// described as a tree of paragraphs, tables, lists, shapes, charts and floats, which is
|
|
13
|
+
// then paginated into a PDF document.
|
|
14
|
+
//
|
|
15
|
+
// Each function below produces one document:
|
|
16
|
+
// * an invoice - tables, cell merging, styling, headers/footers, images
|
|
17
|
+
// * a report - sections, page setup, lists, charts, page numbers
|
|
18
|
+
// * a newsletter - shapes, shape text boxes, floats, hyperlinks, tab stops
|
|
19
|
+
// * a content tree walk - post-processing of an existing content tree
|
|
20
|
+
//---------------------------------------------------------------------------------------
|
|
21
|
+
|
|
9
22
|
((exports) => {
|
|
10
23
|
'use strict';
|
|
11
24
|
|
|
12
25
|
exports.runDocumentCreationTest = async () => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
26
|
+
|
|
27
|
+
const inputPath = '../TestFiles/';
|
|
28
|
+
const outputPath = '../TestFiles/Output/';
|
|
29
|
+
|
|
30
|
+
const moneyToString = (val) => '$' + val.toFixed(2);
|
|
31
|
+
|
|
32
|
+
//-------------------------------------------------------------------------------
|
|
33
|
+
// Small helpers shared by the samples below.
|
|
34
|
+
//-------------------------------------------------------------------------------
|
|
35
|
+
|
|
36
|
+
// Adds a paragraph with the given text and applies a simple heading style.
|
|
37
|
+
const addHeading = async (container, text, font_size, red, green, blue) => {
|
|
38
|
+
const heading = await container.addParagraphWithText(text);
|
|
39
|
+
const style = await heading.getTextStyledElement();
|
|
40
|
+
style.setFontSize(font_size);
|
|
41
|
+
style.setBold(true);
|
|
42
|
+
style.setTextColor(red, green, blue);
|
|
43
|
+
heading.setSpaceBefore(12);
|
|
44
|
+
heading.setSpaceAfter(6);
|
|
45
|
+
return heading;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// Adds a single table row filled with the given texts.
|
|
49
|
+
const addTableRowWithText = async (table, texts, bold, back_red, back_green, back_blue) => {
|
|
50
|
+
const row = await table.addTableRow();
|
|
51
|
+
for (let i = 0; i < texts.length; i++) {
|
|
52
|
+
const cell = await row.addTableCell();
|
|
53
|
+
cell.setBackgroundColor(back_red, back_green, back_blue);
|
|
54
|
+
cell.setVerticalAlignment(PDFNet.TableCell.AlignmentVertical.e_alignment_center);
|
|
55
|
+
|
|
56
|
+
const para = await cell.addParagraphWithText(texts[i]);
|
|
57
|
+
para.setStartIndent(3);
|
|
58
|
+
const style = await para.getTextStyledElement();
|
|
59
|
+
style.setFontSize(10);
|
|
60
|
+
style.setBold(bold);
|
|
61
|
+
|
|
62
|
+
// Right align everything but the first (description) column.
|
|
63
|
+
para.setJustificationMode(i === 0
|
|
64
|
+
? PDFNet.Paragraph.TextJustification.e_text_justify_left
|
|
65
|
+
: PDFNet.Paragraph.TextJustification.e_text_justify_right);
|
|
66
|
+
}
|
|
67
|
+
return row;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// Adds a "Page X of Y" footer to the given section, for all page groups.
|
|
71
|
+
const addPageNumberFooter = async (section, title) => {
|
|
72
|
+
const groups = [
|
|
73
|
+
PDFNet.Section.PageGroup.e_first_page,
|
|
74
|
+
PDFNet.Section.PageGroup.e_even_pages,
|
|
75
|
+
PDFNet.Section.PageGroup.e_odd_pages];
|
|
76
|
+
|
|
77
|
+
for (const group of groups) {
|
|
78
|
+
const footer = await section.getOrCreateFooter(group);
|
|
79
|
+
|
|
80
|
+
const para = await footer.addParagraph();
|
|
81
|
+
para.setJustificationMode(PDFNet.Paragraph.TextJustification.e_text_justify_center);
|
|
82
|
+
|
|
83
|
+
const style = await para.getTextStyledElement();
|
|
84
|
+
style.setFontSize(9);
|
|
85
|
+
style.setTextColor(120, 120, 120);
|
|
86
|
+
style.setItalic(true);
|
|
87
|
+
|
|
88
|
+
await para.addText(title + ' | Page ');
|
|
89
|
+
await para.addPageNumber(PDFNet.PageNumber.NumberType.e_current_page);
|
|
90
|
+
await para.addText(' of ');
|
|
91
|
+
await para.addPageNumber(PDFNet.PageNumber.NumberType.e_total_pages);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
//-------------------------------------------------------------------------------
|
|
96
|
+
// 1. An invoice: a header with a logo float, an addresses table, a line item
|
|
97
|
+
// table with merged cells and a totals block.
|
|
98
|
+
//-------------------------------------------------------------------------------
|
|
99
|
+
const createInvoice = async () => {
|
|
100
|
+
const doc = await PDFNet.FlowDocument.create();
|
|
101
|
+
doc.setDefaultPageSize(612, 792); // US Letter, in points.
|
|
102
|
+
doc.setDefaultMargins(54, 54, 54, 54);
|
|
103
|
+
|
|
104
|
+
const section = await doc.getCurrentSection();
|
|
105
|
+
|
|
106
|
+
// --- Header ----------------------------------------------------------------
|
|
107
|
+
const header = await section.getOrCreateHeader(PDFNet.Section.PageGroup.e_odd_pages);
|
|
108
|
+
const header_para = await header.addParagraphWithText('SYH Supply Co.');
|
|
109
|
+
header_para.setJustificationMode(PDFNet.Paragraph.TextJustification.e_text_justify_right);
|
|
110
|
+
const header_style = await header_para.getTextStyledElement();
|
|
111
|
+
header_style.setFontSize(9);
|
|
112
|
+
header_style.setTextColor(120, 120, 120);
|
|
113
|
+
|
|
114
|
+
await addPageNumberFooter(section, 'Invoice INV-2025-0042');
|
|
115
|
+
|
|
116
|
+
// --- Title, with the company logo floated to the right ---------------------
|
|
117
|
+
const title = await doc.addParagraph();
|
|
118
|
+
|
|
119
|
+
// A float takes its content out of the main flow and positions it relative to
|
|
120
|
+
// a reference point, with the document content wrapped around it.
|
|
121
|
+
const logo_float = await title.addFloat();
|
|
122
|
+
logo_float.setHorizontalReferencePoint(PDFNet.Float.ReferencePoint.e_reference_page);
|
|
123
|
+
logo_float.setVerticalReferencePoint(PDFNet.Float.ReferencePoint.e_reference_paragraph);
|
|
124
|
+
logo_float.setPositionX(400);
|
|
125
|
+
logo_float.setPositionY(0);
|
|
126
|
+
logo_float.setObstructionType(PDFNet.Float.ObstructionType.e_square);
|
|
127
|
+
await (await logo_float.addParagraph()).addImage(96, 96, inputPath + 'logo_red.png');
|
|
128
|
+
|
|
129
|
+
await title.addText('INVOICE');
|
|
130
|
+
const title_style = await title.getTextStyledElement();
|
|
131
|
+
title_style.setFontSize(28);
|
|
132
|
+
title_style.setBold(true);
|
|
133
|
+
title_style.setTextColor(0, 51, 102);
|
|
134
|
+
|
|
135
|
+
const subtitle = await doc.addParagraphWithText(
|
|
136
|
+
'Invoice #INV-2025-0042\nIssued: March 14, 2025\nDue: April 13, 2025');
|
|
137
|
+
(await subtitle.getTextStyledElement()).setFontSize(10);
|
|
138
|
+
subtitle.setSpaceAfter(18);
|
|
139
|
+
|
|
140
|
+
// --- Bill to / ship to -----------------------------------------------------
|
|
141
|
+
const addresses = await doc.addTable();
|
|
142
|
+
addresses.setDefaultColumnWidth(240);
|
|
143
|
+
addresses.setDefaultRowHeight(16);
|
|
144
|
+
|
|
145
|
+
const address_row = await addresses.addTableRow();
|
|
146
|
+
const address_titles = ['BILL TO', 'SHIP TO'];
|
|
147
|
+
const address_bodies = [
|
|
148
|
+
'Contoso Ltd.\n123 Maple Street\nVancouver, BC V6B 1A1\nCanada',
|
|
149
|
+
'Contoso Warehouse #4\n980 Industrial Way\nBurnaby, BC V5J 3J1\nCanada'];
|
|
150
|
+
|
|
151
|
+
for (let i = 0; i < 2; i++) {
|
|
152
|
+
const cell = await address_row.addTableCell();
|
|
153
|
+
cell.setBackgroundColor(240, 244, 248);
|
|
154
|
+
cell.setBorder(0.5, 200, 210, 220);
|
|
155
|
+
|
|
156
|
+
const caption = await cell.addParagraphWithText(address_titles[i]);
|
|
157
|
+
caption.setStartIndent(3);
|
|
158
|
+
const caption_style = await caption.getTextStyledElement();
|
|
159
|
+
caption_style.setFontSize(9);
|
|
160
|
+
caption_style.setBold(true);
|
|
161
|
+
caption_style.setTextColor(0, 51, 102);
|
|
162
|
+
|
|
163
|
+
const body = await cell.addParagraphWithText(address_bodies[i]);
|
|
164
|
+
body.setStartIndent(3);
|
|
165
|
+
(await body.getTextStyledElement()).setFontSize(10);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
await doc.addParagraphWithText(' ');
|
|
169
|
+
|
|
170
|
+
// --- Line items ------------------------------------------------------------
|
|
171
|
+
const items = await doc.addTable();
|
|
172
|
+
items.setDefaultColumnWidth(120);
|
|
173
|
+
items.setDefaultRowHeight(18);
|
|
174
|
+
items.setBorder(0.75, 0, 51, 102);
|
|
175
|
+
|
|
176
|
+
const headers = ['Description', 'Qty', 'Unit price', 'Amount'];
|
|
177
|
+
const header_row = await addTableRowWithText(items, headers, true, 0, 51, 102);
|
|
178
|
+
|
|
179
|
+
// Make the header row text white by walking the row we have just created.
|
|
180
|
+
const cell_itr = await header_row.getContentNodeIterator();
|
|
181
|
+
while (await cell_itr.hasNext()) {
|
|
182
|
+
const cell = await (await cell_itr.current()).asTableCell();
|
|
183
|
+
if (cell !== null) {
|
|
184
|
+
const para_itr = await cell.getContentNodeIterator();
|
|
185
|
+
while (await para_itr.hasNext()) {
|
|
186
|
+
const para = await (await para_itr.current()).asParagraph();
|
|
187
|
+
if (para !== null) {
|
|
188
|
+
(await para.getTextStyledElement()).setTextColor(255, 255, 255);
|
|
189
|
+
}
|
|
190
|
+
await para_itr.next();
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
await cell_itr.next();
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const line_descriptions = [
|
|
197
|
+
'Height adjustable desk, oak finish',
|
|
198
|
+
'Ergonomic office chair',
|
|
199
|
+
'Meeting room whiteboard, 180 cm',
|
|
200
|
+
'On-site assembly and delivery'];
|
|
201
|
+
const line_quantities = [2, 5, 1, 1];
|
|
202
|
+
const line_prices = [4800.00, 950.00, 1200.00, 2500.00];
|
|
203
|
+
const num_line_items = line_descriptions.length;
|
|
204
|
+
|
|
205
|
+
let subtotal = 0;
|
|
206
|
+
for (let i = 0; i < num_line_items; i++) {
|
|
207
|
+
const amount = line_quantities[i] * line_prices[i];
|
|
208
|
+
subtotal += amount;
|
|
209
|
+
|
|
210
|
+
const cells = [
|
|
211
|
+
line_descriptions[i],
|
|
212
|
+
line_quantities[i].toString(),
|
|
213
|
+
moneyToString(line_prices[i]),
|
|
214
|
+
moneyToString(amount)];
|
|
215
|
+
|
|
216
|
+
// Alternating row background for readability.
|
|
217
|
+
const even = (i % 2) === 0;
|
|
218
|
+
await addTableRowWithText(items, cells, false,
|
|
219
|
+
even ? 255 : 240, even ? 255 : 244, even ? 255 : 248);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const tax = subtotal * 0.12;
|
|
223
|
+
|
|
224
|
+
const total_labels = ['Subtotal', 'GST/PST (12%)', 'Total due (CAD)'];
|
|
225
|
+
const total_values = [subtotal, tax, subtotal + tax];
|
|
226
|
+
const total_bold = [false, false, true];
|
|
227
|
+
|
|
228
|
+
for (let i = 0; i < total_labels.length; i++) {
|
|
229
|
+
const cells = ['', '', total_labels[i], moneyToString(total_values[i])];
|
|
230
|
+
await addTableRowWithText(items, cells, total_bold[i], 255, 255, 255);
|
|
231
|
+
|
|
232
|
+
// Merge the two empty leading cells of the totals row.
|
|
233
|
+
(await items.getTableCell(0, num_line_items + 1 + i)).mergeCellsRight(1);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const notes = await doc.addParagraphWithText(
|
|
237
|
+
'Payment is due within 30 days. Late payments are subject to a 1.5% monthly '
|
|
238
|
+
+ 'interest charge. Please reference the invoice number with your payment.');
|
|
239
|
+
notes.setSpaceBefore(24);
|
|
240
|
+
const notes_style = await notes.getTextStyledElement();
|
|
241
|
+
notes_style.setFontSize(9);
|
|
242
|
+
notes_style.setItalic(true);
|
|
243
|
+
notes_style.setTextColor(90, 90, 90);
|
|
244
|
+
|
|
245
|
+
const signature = await doc.addParagraph();
|
|
246
|
+
signature.setSpaceBefore(18);
|
|
247
|
+
await signature.addImage(140, 50, inputPath + 'signature.jpg');
|
|
248
|
+
await signature.addText('\nAuthorized signature');
|
|
249
|
+
|
|
250
|
+
const pdf = await doc.paginateToPDF();
|
|
251
|
+
await pdf.save(outputPath + 'created_invoice.pdf', PDFNet.SDFDoc.SaveOptions.e_linearized);
|
|
252
|
+
console.log('Saved created_invoice.pdf');
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
//-------------------------------------------------------------------------------
|
|
256
|
+
// 2. A two page report. The first page (portrait) holds a data table, the second
|
|
257
|
+
// one is a separate landscape section holding a chart.
|
|
258
|
+
//-------------------------------------------------------------------------------
|
|
259
|
+
const createReportWithChart = async () => {
|
|
260
|
+
const doc = await PDFNet.FlowDocument.create();
|
|
261
|
+
doc.setDefaultPageSize(612, 792);
|
|
262
|
+
doc.setDefaultMargins(72, 72, 72, 72);
|
|
263
|
+
|
|
264
|
+
//--- Page 1: portrait section with the data table ---------------------------
|
|
265
|
+
const data_section = await doc.getCurrentSection();
|
|
266
|
+
await addPageNumberFooter(data_section, 'Quarterly Revenue Report');
|
|
267
|
+
|
|
268
|
+
await addHeading(doc, 'Quarterly Revenue Report 2025', 22, 0, 51, 102);
|
|
269
|
+
|
|
270
|
+
const intro = await doc.addParagraphWithText(
|
|
271
|
+
'The table below summarizes the revenue by region for the first three quarters '
|
|
272
|
+
+ 'of the fiscal year. All figures are given in thousands of Canadian dollars '
|
|
273
|
+
+ 'and exclude intercompany transactions.');
|
|
274
|
+
(await intro.getTextStyledElement()).setFontSize(11);
|
|
275
|
+
intro.setSpaceAfter(12);
|
|
276
|
+
|
|
277
|
+
const table = await doc.addTable();
|
|
278
|
+
table.setDefaultColumnWidth(90);
|
|
279
|
+
table.setDefaultRowHeight(18);
|
|
280
|
+
table.setBorder(0.75, 120, 120, 120);
|
|
281
|
+
|
|
282
|
+
const header_cells = ['Region', 'Q1', 'Q2', 'Q3', 'Total'];
|
|
283
|
+
await addTableRowWithText(table, header_cells, true, 220, 230, 240);
|
|
284
|
+
|
|
285
|
+
const region_names = ['North America', 'Europe', 'Asia Pacific', 'Latin America'];
|
|
286
|
+
const region_values = [
|
|
287
|
+
[1250, 1410, 1580],
|
|
288
|
+
[910, 980, 1120],
|
|
289
|
+
[640, 720, 905],
|
|
290
|
+
[310, 355, 390]];
|
|
291
|
+
|
|
292
|
+
const totals = [0, 0, 0];
|
|
293
|
+
for (let i = 0; i < region_names.length; i++) {
|
|
294
|
+
totals[0] += region_values[i][0];
|
|
295
|
+
totals[1] += region_values[i][1];
|
|
296
|
+
totals[2] += region_values[i][2];
|
|
297
|
+
|
|
298
|
+
const row_total = region_values[i][0] + region_values[i][1] + region_values[i][2];
|
|
299
|
+
const cells = [
|
|
300
|
+
region_names[i],
|
|
301
|
+
region_values[i][0].toString(),
|
|
302
|
+
region_values[i][1].toString(),
|
|
303
|
+
region_values[i][2].toString(),
|
|
304
|
+
row_total.toString()];
|
|
305
|
+
await addTableRowWithText(table, cells, false, 255, 255, 255);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
const total_cells = ['All regions',
|
|
309
|
+
totals[0].toString(),
|
|
310
|
+
totals[1].toString(),
|
|
311
|
+
totals[2].toString(),
|
|
312
|
+
(totals[0] + totals[1] + totals[2]).toString()];
|
|
313
|
+
await addTableRowWithText(table, total_cells, true, 240, 240, 240);
|
|
314
|
+
|
|
315
|
+
await addHeading(doc, 'Key observations', 14, 0, 51, 102);
|
|
316
|
+
|
|
317
|
+
const observations = await doc.addList();
|
|
318
|
+
observations.setNumberFormat(PDFNet.List.NumberFormat.e_decimal, '.', true);
|
|
319
|
+
(await observations.getLabelStyle()).setBold(true);
|
|
320
|
+
await (await observations.addItem()).addParagraphWithText(
|
|
321
|
+
'Revenue grew in every region, with Asia Pacific showing the strongest '
|
|
322
|
+
+ 'quarter over quarter growth.');
|
|
323
|
+
await (await observations.addItem()).addParagraphWithText(
|
|
324
|
+
'North America remains the largest market, contributing roughly 40% of '
|
|
325
|
+
+ 'the total revenue.');
|
|
326
|
+
|
|
327
|
+
const risks = await observations.addItem();
|
|
328
|
+
await risks.addParagraphWithText('Risks that may affect the Q4 forecast:');
|
|
329
|
+
const risk_list = await risks.addList();
|
|
330
|
+
risk_list.setNumberFormat(PDFNet.List.NumberFormat.e_lower_letter, ')', true);
|
|
331
|
+
await (await risk_list.addItem()).addParagraphWithText('Currency fluctuations in Latin America.');
|
|
332
|
+
await (await risk_list.addItem()).addParagraphWithText('Longer sales cycles in the enterprise segment.');
|
|
333
|
+
|
|
334
|
+
//--- Page 2: landscape section with the chart -------------------------------
|
|
335
|
+
const chart_section = await doc.addSection();
|
|
336
|
+
chart_section.setPageSize(792, 612); // landscape
|
|
337
|
+
chart_section.setMargins(54, 54, 54, 54);
|
|
338
|
+
await addPageNumberFooter(chart_section, 'Quarterly Revenue Report');
|
|
339
|
+
|
|
340
|
+
await addHeading(doc, 'Revenue by region and quarter', 18, 0, 51, 102);
|
|
341
|
+
|
|
342
|
+
// A chart is described by a JSON definition string.
|
|
343
|
+
const chart_definition = JSON.stringify({
|
|
344
|
+
chartType: 'bar',
|
|
345
|
+
title: 'Revenue by region (thousands CAD)',
|
|
346
|
+
theme: 'vivid',
|
|
347
|
+
data: {
|
|
348
|
+
categories: { data: ['Q1', 'Q2', 'Q3'] },
|
|
349
|
+
series: region_names.map((name, i) => ({
|
|
350
|
+
name: { data: [name] },
|
|
351
|
+
data: { data: region_values[i] }
|
|
352
|
+
}))
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
const chart_para = await doc.addParagraph();
|
|
357
|
+
chart_para.setJustificationMode(PDFNet.Paragraph.TextJustification.e_text_justify_center);
|
|
358
|
+
const chart = await chart_para.addChart(560, 340, chart_definition);
|
|
359
|
+
chart.setWidth(600);
|
|
360
|
+
chart.setHeight(360);
|
|
361
|
+
|
|
362
|
+
const caption = await doc.addParagraphWithText(
|
|
363
|
+
'Figure 1: revenue distribution across the four sales regions.');
|
|
364
|
+
caption.setJustificationMode(PDFNet.Paragraph.TextJustification.e_text_justify_center);
|
|
365
|
+
const caption_style = await caption.getTextStyledElement();
|
|
366
|
+
caption_style.setItalic(true);
|
|
367
|
+
caption_style.setFontSize(10);
|
|
368
|
+
|
|
369
|
+
console.log('Report sections: ' + (await doc.getNumSections())
|
|
370
|
+
+ ', second section page width: ' + (await (await doc.getSection(1)).getPageWidth()));
|
|
371
|
+
|
|
372
|
+
const pdf = await doc.paginateToPDF();
|
|
373
|
+
await pdf.save(outputPath + 'created_report.pdf', PDFNet.SDFDoc.SaveOptions.e_linearized);
|
|
374
|
+
console.log('Saved created_report.pdf');
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
//-------------------------------------------------------------------------------
|
|
378
|
+
// 3. A newsletter demonstrating shapes, shape text boxes, floats, hyperlinks and
|
|
379
|
+
// paragraph styling such as indents, tab stops and justification.
|
|
380
|
+
//-------------------------------------------------------------------------------
|
|
381
|
+
const createNewsletter = async () => {
|
|
382
|
+
const body_text =
|
|
383
|
+
'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod '
|
|
384
|
+
+ 'tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, '
|
|
385
|
+
+ 'quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo '
|
|
386
|
+
+ 'consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse '
|
|
387
|
+
+ 'cillum dolore eu fugiat nulla pariatur.';
|
|
388
|
+
|
|
389
|
+
const doc = await PDFNet.FlowDocument.create();
|
|
390
|
+
doc.setDefaultPageSize(612, 792);
|
|
391
|
+
doc.setDefaultMargins(60, 60, 60, 60);
|
|
392
|
+
|
|
393
|
+
const section = await doc.getCurrentSection();
|
|
394
|
+
await addPageNumberFooter(section, 'The Monthly Dispatch');
|
|
395
|
+
|
|
396
|
+
// Masthead built from a rounded rectangle shape with a text box inside.
|
|
397
|
+
const masthead_para = await doc.addParagraph();
|
|
398
|
+
const masthead = await masthead_para.addShape(
|
|
399
|
+
PDFNet.Shape.Type.e_rectangle_rounded_corners, 492, 70);
|
|
400
|
+
masthead.setCornerRadius(10);
|
|
401
|
+
masthead.setBackgroundColor(0, 51, 102);
|
|
402
|
+
masthead.setOutlineColor(0, 31, 62);
|
|
403
|
+
masthead.setOutlineThickness(1.5);
|
|
404
|
+
|
|
405
|
+
const masthead_text = await masthead.getTextBox();
|
|
406
|
+
const masthead_title = await masthead_text.addParagraphWithText('The Monthly Dispatch');
|
|
407
|
+
masthead_title.setJustificationMode(PDFNet.Paragraph.TextJustification.e_text_justify_center);
|
|
408
|
+
const masthead_style = await masthead_title.getTextStyledElement();
|
|
409
|
+
masthead_style.setFontSize(24);
|
|
410
|
+
masthead_style.setBold(true);
|
|
411
|
+
masthead_style.setTextColor(255, 255, 255);
|
|
412
|
+
|
|
413
|
+
const masthead_sub = await masthead_text.addParagraphWithText('Issue 42 - March 2025');
|
|
414
|
+
masthead_sub.setJustificationMode(PDFNet.Paragraph.TextJustification.e_text_justify_center);
|
|
415
|
+
const masthead_sub_style = await masthead_sub.getTextStyledElement();
|
|
416
|
+
masthead_sub_style.setFontSize(10);
|
|
417
|
+
masthead_sub_style.setTextColor(200, 215, 230);
|
|
418
|
+
|
|
419
|
+
// Lead story with a pull quote floated next to it.
|
|
420
|
+
await addHeading(doc, 'Documents, assembled', 16, 0, 51, 102);
|
|
421
|
+
|
|
422
|
+
const lead = await doc.addParagraph();
|
|
423
|
+
lead.setJustificationMode(PDFNet.Paragraph.TextJustification.e_text_justify_left);
|
|
424
|
+
lead.setTextIndent(18);
|
|
425
|
+
lead.setSpaceAfter(10);
|
|
426
|
+
|
|
427
|
+
const pull_quote = await lead.addFloat();
|
|
428
|
+
pull_quote.setHorizontalReferencePoint(PDFNet.Float.ReferencePoint.e_reference_page);
|
|
429
|
+
pull_quote.setVerticalReferencePoint(PDFNet.Float.ReferencePoint.e_reference_paragraph);
|
|
430
|
+
pull_quote.setPositionX(380);
|
|
431
|
+
pull_quote.setPositionY(10);
|
|
432
|
+
pull_quote.setObstructionType(PDFNet.Float.ObstructionType.e_square);
|
|
433
|
+
|
|
434
|
+
const quote_holder = await pull_quote.addParagraph();
|
|
435
|
+
const quote_box = await quote_holder.addShape(
|
|
436
|
+
PDFNet.Shape.Type.e_rectangle_rounded_corners, 190, 70);
|
|
437
|
+
quote_box.setCornerRadius(6);
|
|
438
|
+
quote_box.setBackgroundColor(240, 246, 255);
|
|
439
|
+
quote_box.setOutlineColor(0, 51, 102);
|
|
440
|
+
quote_box.setOutlineThickness(1.0);
|
|
441
|
+
|
|
442
|
+
const quote_text = await quote_box.getTextBox();
|
|
443
|
+
const quote = await quote_text.addParagraphWithText(
|
|
444
|
+
'"The content tree lets you describe a document, not a page."');
|
|
445
|
+
quote.setStartIndent(6);
|
|
446
|
+
quote.setEndIndent(6);
|
|
447
|
+
const quote_style = await quote.getTextStyledElement();
|
|
448
|
+
quote_style.setFontSize(12);
|
|
449
|
+
quote_style.setItalic(true);
|
|
450
|
+
quote_style.setTextColor(0, 51, 102);
|
|
451
|
+
|
|
452
|
+
await lead.addText(body_text);
|
|
453
|
+
await lead.addText(' Read more about the API at ');
|
|
454
|
+
const link = await lead.addHyperlink('apryse.com', 'https://www.apryse.com');
|
|
455
|
+
(await link.getTextStyledElement()).setTextColor(0, 102, 204);
|
|
456
|
+
await lead.addText('.');
|
|
457
|
+
|
|
458
|
+
// Two "columns" of text, created with complementary indents.
|
|
459
|
+
const column_left = await doc.addParagraphWithText(body_text);
|
|
460
|
+
column_left.setStartIndent(0);
|
|
461
|
+
column_left.setEndIndent(260);
|
|
462
|
+
(await column_left.getTextStyledElement()).setFontSize(10);
|
|
463
|
+
|
|
464
|
+
const column_right = await doc.addParagraphWithText(body_text);
|
|
465
|
+
column_right.setStartIndent(260);
|
|
466
|
+
column_right.setEndIndent(0);
|
|
467
|
+
(await column_right.getTextStyledElement()).setFontSize(10);
|
|
468
|
+
|
|
469
|
+
// A schedule built with tab stops instead of a table.
|
|
470
|
+
await addHeading(doc, 'Upcoming webinars', 14, 0, 51, 102);
|
|
471
|
+
|
|
472
|
+
const schedule = [
|
|
473
|
+
['Apr 02', 'Building documents from scratch', 'R. Fischer'],
|
|
474
|
+
['Apr 16', 'Charts and data visualization', 'M. Okafor'],
|
|
475
|
+
['Apr 30', 'Accessible PDF output', 'L. Tanaka']];
|
|
476
|
+
|
|
477
|
+
for (const webinar of schedule) {
|
|
478
|
+
const row = await doc.addParagraph();
|
|
479
|
+
row.addTabStop(80);
|
|
480
|
+
row.addTabStop(360);
|
|
481
|
+
(await row.getTextStyledElement()).setFontSize(10);
|
|
482
|
+
await row.addText(webinar[0] + '\t' + webinar[1] + '\t' + webinar[2]);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
// A decorative arrow and a photo, both anchored in a single paragraph.
|
|
486
|
+
const gallery = await doc.addParagraph();
|
|
487
|
+
gallery.setSpaceBefore(16);
|
|
488
|
+
gallery.setJustificationMode(PDFNet.Paragraph.TextJustification.e_text_justify_center);
|
|
489
|
+
|
|
490
|
+
const arrow = await gallery.addShape(PDFNet.Shape.Type.e_arrow, 90, 40);
|
|
491
|
+
arrow.setBackgroundColor(0, 153, 102);
|
|
492
|
+
arrow.setOutlineColor(0, 102, 68);
|
|
493
|
+
arrow.setOutlineThickness(1);
|
|
494
|
+
arrow.setArrowHeadSize(18);
|
|
495
|
+
|
|
496
|
+
await gallery.addText(' ');
|
|
497
|
+
await gallery.addImage(160, 120, inputPath + 'butterfly.png');
|
|
498
|
+
|
|
499
|
+
const pdf = await doc.paginateToPDF();
|
|
500
|
+
await pdf.save(outputPath + 'created_newsletter.pdf', PDFNet.SDFDoc.SaveOptions.e_linearized);
|
|
501
|
+
console.log('Saved created_newsletter.pdf');
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
//-------------------------------------------------------------------------------
|
|
505
|
+
// 4. Post-processing: build a simple document and then walk its content tree,
|
|
506
|
+
// restyling the elements that are found along the way.
|
|
507
|
+
//-------------------------------------------------------------------------------
|
|
508
|
+
|
|
509
|
+
// Recursively walks the content tree, highlighting every second text run and
|
|
510
|
+
// outlining the cells of any table that is encountered.
|
|
511
|
+
const restyleContentTree = async (node, highlight) => {
|
|
18
512
|
const itr = await node.getContentNodeIterator();
|
|
19
513
|
while (await itr.hasNext()) {
|
|
20
514
|
const el = await itr.current();
|
|
21
|
-
itr.next();
|
|
22
|
-
|
|
515
|
+
await itr.next();
|
|
516
|
+
|
|
23
517
|
const text_run = await el.asTextRun();
|
|
24
518
|
if (text_run !== null) {
|
|
25
|
-
if (
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
519
|
+
if (highlight) {
|
|
520
|
+
const style = await text_run.getTextStyledElement();
|
|
521
|
+
style.setBold(true);
|
|
522
|
+
style.setBackgroundColor(255, 245, 180);
|
|
29
523
|
}
|
|
30
|
-
|
|
524
|
+
highlight = !highlight;
|
|
31
525
|
continue;
|
|
32
526
|
}
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
|
|
527
|
+
|
|
528
|
+
const cell = await el.asTableCell();
|
|
529
|
+
if (cell !== null) {
|
|
530
|
+
cell.setBorder(0.5, 150, 150, 150);
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
const child = await el.asContentNode();
|
|
534
|
+
if (child !== null) {
|
|
535
|
+
highlight = await restyleContentTree(child, highlight);
|
|
38
536
|
}
|
|
39
537
|
}
|
|
538
|
+
return highlight;
|
|
40
539
|
};
|
|
41
540
|
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
}
|
|
541
|
+
const restyleExistingContent = async () => {
|
|
542
|
+
const doc = await PDFNet.FlowDocument.create();
|
|
543
|
+
doc.setDefaultPageSize(612, 792);
|
|
544
|
+
doc.setDefaultMargins(72, 72, 72, 72);
|
|
91
545
|
|
|
92
|
-
|
|
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
|
-
}
|
|
546
|
+
await addHeading(doc, 'Content tree post-processing', 18, 0, 51, 102);
|
|
168
547
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
548
|
+
for (let i = 0; i < 4; i++) {
|
|
549
|
+
const para = await doc.addParagraph();
|
|
550
|
+
para.setSpaceAfter(8);
|
|
551
|
+
await para.addText('Sentence ' + (i * 2) + '. ');
|
|
552
|
+
await para.addText('Sentence ' + (i * 2 + 1) + '. ');
|
|
553
|
+
await para.addText('The style of these runs is decided after the fact.');
|
|
554
|
+
}
|
|
177
555
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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
|
-
}
|
|
556
|
+
const table = await doc.addTable();
|
|
557
|
+
table.setDefaultColumnWidth(150);
|
|
558
|
+
table.setDefaultRowHeight(16);
|
|
275
559
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
560
|
+
for (let row_index = 0; row_index < 3; row_index++) {
|
|
561
|
+
const row = await table.addTableRow();
|
|
562
|
+
for (let col_index = 0; col_index < 3; col_index++) {
|
|
563
|
+
const cell = await row.addTableCell();
|
|
564
|
+
await cell.addParagraphWithText('R' + row_index + ' / C' + col_index);
|
|
279
565
|
}
|
|
566
|
+
}
|
|
280
567
|
|
|
281
|
-
|
|
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
|
-
}
|
|
568
|
+
await restyleContentTree(doc, false);
|
|
337
569
|
|
|
338
|
-
|
|
339
|
-
|
|
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
|
-
}
|
|
570
|
+
console.log('Table has ' + (await table.getNumRows()) + ' rows and '
|
|
571
|
+
+ (await table.getNumColumns()) + ' columns.');
|
|
389
572
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
573
|
+
const pdf = await doc.paginateToPDF();
|
|
574
|
+
await pdf.save(outputPath + 'created_restyled.pdf', PDFNet.SDFDoc.SaveOptions.e_linearized);
|
|
575
|
+
console.log('Saved created_restyled.pdf');
|
|
576
|
+
};
|
|
393
577
|
|
|
394
|
-
|
|
395
|
-
|
|
578
|
+
const main = async () => {
|
|
579
|
+
try {
|
|
580
|
+
await createInvoice();
|
|
581
|
+
await createReportWithChart();
|
|
582
|
+
await createNewsletter();
|
|
583
|
+
await restyleExistingContent();
|
|
396
584
|
console.log('Done.');
|
|
397
585
|
} catch (err) {
|
|
398
|
-
|
|
586
|
+
console.log(err);
|
|
399
587
|
}
|
|
400
588
|
};
|
|
401
589
|
|
package/LicenseKey/LicenseKey.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-
|
|
2
|
+
// Copyright (c) 2001-2026 by Apryse Software Inc. All Rights Reserved.
|
|
3
3
|
// Consult legal.txt regarding legal and license information.
|
|
4
4
|
//---------------------------------------------------------------------------------------
|
|
5
5
|
|
package/OCRTest/OCRTest.js
CHANGED
|
@@ -221,6 +221,59 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
221
221
|
} catch (err) {
|
|
222
222
|
console.log(err);
|
|
223
223
|
}
|
|
224
|
+
|
|
225
|
+
//--------------------------------------------------------------------------------
|
|
226
|
+
// Example 7) Check whether a page needs OCR before running it, to avoid unnecessary OCR processing on pages that already contain extractable text
|
|
227
|
+
// lorem_ipsum.pdf and newsletter.pdf already exist in the general TestFiles folder, so they are
|
|
228
|
+
// referenced there instead of duplicating them into the OCR-specific TestFiles/OCR folder.
|
|
229
|
+
const test_files_path = '../TestFiles/';
|
|
230
|
+
|
|
231
|
+
try {
|
|
232
|
+
// A) Positive test: lorem_ipsum.pdf is a scanned document with no extractable text, so it should need OCR.
|
|
233
|
+
const scannedDoc = await PDFNet.PDFDoc.createFromFilePath(test_files_path + 'lorem_ipsum.pdf');
|
|
234
|
+
await scannedDoc.initSecurityHandler();
|
|
235
|
+
const scannedPage = await scannedDoc.getPage(1);
|
|
236
|
+
|
|
237
|
+
// Ask OCRModule whether the page needs OCR. Passing accept_invisible_text as false
|
|
238
|
+
// means invisible text (e.g. from a prior OCR pass) is ignored and only visible content
|
|
239
|
+
// is considered, while true would treat an existing invisible text layer as sufficient
|
|
240
|
+
// to consider the page as not needing OCR.
|
|
241
|
+
const scannedNeedsOCR = await PDFNet.OCRModule.pageNeedsOCR(scannedPage, false);
|
|
242
|
+
console.log('Example 7 (positive test): page 1 of lorem_ipsum.pdf ' + (scannedNeedsOCR ? 'needs' : 'does not need') + ' OCR');
|
|
243
|
+
|
|
244
|
+
// Only run OCR if it is actually needed
|
|
245
|
+
if (scannedNeedsOCR) {
|
|
246
|
+
const opts = new PDFNet.OCRModule.OCROptions();
|
|
247
|
+
if(useIRIS) opts.setOCREngine('iris');
|
|
248
|
+
opts.addLang('eng');
|
|
249
|
+
await PDFNet.OCRModule.processPDF(scannedDoc, opts);
|
|
250
|
+
await scannedDoc.save(output_path + 'lorem_ipsum_conditional.pdf', 0);
|
|
251
|
+
}
|
|
252
|
+
} catch (err) {
|
|
253
|
+
console.log(err);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
try {
|
|
257
|
+
// B) Negative test: newsletter.pdf already contains extractable text, so it should not need OCR.
|
|
258
|
+
const newsletterDoc = await PDFNet.PDFDoc.createFromFilePath(test_files_path + 'newsletter.pdf');
|
|
259
|
+
await newsletterDoc.initSecurityHandler();
|
|
260
|
+
const newsletterPage = await newsletterDoc.getPage(1);
|
|
261
|
+
|
|
262
|
+
const newsletterNeedsOCR = await PDFNet.OCRModule.pageNeedsOCR(newsletterPage, false);
|
|
263
|
+
console.log('Example 7 (negative test): page 1 of newsletter.pdf ' + (newsletterNeedsOCR ? 'needs' : 'does not need') + ' OCR');
|
|
264
|
+
|
|
265
|
+
// Only run OCR if it is actually needed
|
|
266
|
+
if (newsletterNeedsOCR) {
|
|
267
|
+
const opts = new PDFNet.OCRModule.OCROptions();
|
|
268
|
+
if(useIRIS) opts.setOCREngine('iris');
|
|
269
|
+
opts.addLang('eng');
|
|
270
|
+
await PDFNet.OCRModule.processPDF(newsletterDoc, opts);
|
|
271
|
+
await newsletterDoc.save(output_path + 'newsletter_conditional.pdf', 0);
|
|
272
|
+
}
|
|
273
|
+
} catch (err) {
|
|
274
|
+
console.log(err);
|
|
275
|
+
}
|
|
276
|
+
|
|
224
277
|
console.log('Done.');
|
|
225
278
|
} catch (err) {
|
|
226
279
|
console.log(err);
|
|
@@ -79,6 +79,29 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
79
79
|
|
|
80
80
|
//////////////////////////////////////////////////////////////////////////
|
|
81
81
|
|
|
82
|
+
try {
|
|
83
|
+
// Convert PDF document to Word with OCR options
|
|
84
|
+
console.log('Converting PDF to Word with OCR options');
|
|
85
|
+
|
|
86
|
+
const outputFile = outputPath + 'US061222892-a.docx';
|
|
87
|
+
|
|
88
|
+
const wordOutputOptions = new PDFNet.Convert.WordOutputOptions();
|
|
89
|
+
|
|
90
|
+
// Use the Paddle OCR engine. Note: unlike the default OCR engine, Paddle does not
|
|
91
|
+
// support automatic language detection, so the OCR language must be set explicitly
|
|
92
|
+
// (the default is English).
|
|
93
|
+
wordOutputOptions.setPreferredOCREngine(PDFNet.Convert.OutputOptionsOCR.PreferredOCREngine.e_engine_paddle);
|
|
94
|
+
wordOutputOptions.setCustomOCRLanguage('eng');
|
|
95
|
+
|
|
96
|
+
await PDFNet.Convert.fileToWord(inputPath + 'US061222892-a.pdf', outputFile, wordOutputOptions);
|
|
97
|
+
|
|
98
|
+
console.log('Result saved in ' + outputFile);
|
|
99
|
+
} catch (err) {
|
|
100
|
+
console.log(err);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
//////////////////////////////////////////////////////////////////////////
|
|
104
|
+
|
|
82
105
|
try {
|
|
83
106
|
// Convert PDF document to Excel
|
|
84
107
|
console.log('Converting PDF to Excel');
|
package/legal.txt
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Legal Notices:
|
|
3
3
|
-----------------------------------------------------------------------------
|
|
4
4
|
|
|
5
|
-
Copyright (c) 2001-
|
|
5
|
+
Copyright (c) 2001-2026 by Apryse Software Inc. All Rights Reserved.
|
|
6
6
|
Apryse, PDFTron and PDFNet SDK are either trademarks and/or service marks
|
|
7
7
|
and/or registered trademarks of Apryse Software Incorporated
|
|
8
8
|
in Canada and/or other countries.
|
|
@@ -124,7 +124,7 @@ and fitness for purpose.
|
|
|
124
124
|
---------------------------------------------------------------------------
|
|
125
125
|
Boost
|
|
126
126
|
|
|
127
|
-
CopyRight (c) 2001-
|
|
127
|
+
CopyRight (c) 2001-2026 by Apryse Software Inc. All Rights Reserved.
|
|
128
128
|
CopyRight Aaron W. LaFramboise, Roland Schwarz, Michael Glassford 2004.
|
|
129
129
|
CopyRight Anthony Williams 2007
|
|
130
130
|
CopyRight Beman Dawes 2002-2010
|
|
@@ -234,7 +234,7 @@ all copies or substantial portions of the Software.
|
|
|
234
234
|
---------------------------------------------------------------------------
|
|
235
235
|
Leptonica
|
|
236
236
|
|
|
237
|
-
Copyright (C) 2001-
|
|
237
|
+
Copyright (C) 2001-2026 Leptonica. All rights reserved.
|
|
238
238
|
|
|
239
239
|
Redistribution and use in source and binary forms, with or without
|
|
240
240
|
modification, are permitted provided that the following conditions
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pdftron/pdfnet-node-samples",
|
|
3
|
-
"version": "12.1
|
|
3
|
+
"version": "12.2.1-beta",
|
|
4
4
|
"description": "Sample code for the @pdftron/pdfnet-node package.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "run-script-os",
|
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
"author": "Apryse Software Inc.",
|
|
12
12
|
"license": "Commercial",
|
|
13
13
|
"homepage": "https://www.apryse.com",
|
|
14
|
+
"repository": "https://github.com/XodoDocs/PDFTronCore.git",
|
|
14
15
|
"dependencies": {
|
|
15
|
-
"@pdftron/pdfnet-node": "^12.1
|
|
16
|
+
"@pdftron/pdfnet-node": "^12.2.1-beta",
|
|
16
17
|
"run-script-os": "^1.1.6",
|
|
17
18
|
"underscore": "^1.13.6",
|
|
18
19
|
"xhr2": "^0.2.1"
|
package/readme.md
CHANGED
|
@@ -5,8 +5,8 @@ This package leverages the full power of Apryse's native SDK for maximal perform
|
|
|
5
5
|
#### Supported platform, Node.js, and Electron versions
|
|
6
6
|
This package depends on unmanaged add-on binaries, and the add-on binaries are not cross-platform. At the moment we have support for
|
|
7
7
|
* **OS**: Linux, Windows(x64), Mac
|
|
8
|
-
* **Node.js version**:
|
|
9
|
-
* **Electron version**:
|
|
8
|
+
* **Node.js version**: 12 - 26
|
|
9
|
+
* **Electron version**: 44 - 44
|
|
10
10
|
|
|
11
11
|
Installation will fail if your OS, Node.js or Electron version is not supported.
|
|
12
12
|
|