@pdftron/pdfnet-node-samples 9.2.0 → 9.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/samples/AddImageTest/AddImageTest.js +115 -115
- package/samples/AdvancedImagingTest/AdvancedImagingTest.js +78 -64
- package/samples/AnnotationTest/AnnotationTest.js +641 -641
- package/samples/BookmarkTest/BookmarkTest.js +219 -219
- package/samples/CAD2PDFTest/CAD2PDFTest.js +4 -4
- package/samples/ContentReplacerTest/ContentReplacerTest.js +75 -75
- package/samples/ConvertTest/ConvertTest.js +5 -5
- package/samples/DigitalSignaturesTest/DigitalSignaturesTest.js +1 -1
- package/samples/ElementBuilderTest/ElementBuilderTest.js +513 -513
- package/samples/ElementEditTest/ElementEditTest.js +110 -110
- package/samples/ElementReaderAdvTest/ElementReaderAdvTest.js +305 -305
- package/samples/ElementReaderTest/ElementReaderTest.js +77 -77
- package/samples/EncTest/EncTest.js +175 -175
- package/samples/FDFTest/FDFTest.js +1 -1
- package/samples/HTML2PDFTest/HTML2PDFTest.js +53 -43
- package/samples/HighlightsTest/HighlightsTest.js +97 -0
- package/samples/ImageExtractTest/ImageExtractTest.js +1 -1
- package/samples/ImpositionTest/ImpositionTest.js +1 -1
- package/samples/InteractiveFormsTest/InteractiveFormsTest.js +1 -1
- package/samples/JBIG2Test/JBIG2Test.js +1 -1
- package/samples/LicenseKey/LicenseKey.js +11 -11
- package/samples/LogicalStructureTest/LogicalStructureTest.js +250 -250
- package/samples/OCRTest/OCRTest.js +19 -34
- package/samples/OfficeTemplateTest/OfficeTemplateTest.js +77 -0
- package/samples/OfficeToPDFTest/OfficeToPDFTest.js +1 -1
- package/samples/OptimizerTest/OptimizerTest.js +1 -1
- package/samples/PDF2HtmlTest/PDF2HtmlTest.js +123 -123
- package/samples/PDF2OfficeTest/PDF2OfficeTest.js +158 -158
- package/samples/PDFATest/PDFATest.js +85 -85
- package/samples/PDFDocMemoryTest/PDFDocMemoryTest.js +1 -1
- package/samples/PDFDrawTest/PDFDrawTest.js +305 -305
- package/samples/PDFLayersTest/PDFLayersTest.js +294 -294
- package/samples/PDFPackageTest/PDFPackageTest.js +1 -1
- package/samples/PDFPageTest/PDFPageTest.js +189 -189
- package/samples/PDFRedactTest/PDFRedactTest.js +74 -74
- package/samples/PageLabelsTest/PageLabelsTest.js +1 -1
- package/samples/PatternTest/PatternTest.js +1 -1
- package/samples/RectTest/RectTest.js +40 -40
- package/samples/SDFTest/SDFTest.js +88 -88
- package/samples/StamperTest/StamperTest.js +255 -255
- package/samples/TestFiles/Misc-Fixed.pfa +1166 -1166
- package/samples/TestFiles/SHA-2 Root USERTrust RSA CA Sectigo timestamping.crt +34 -34
- package/samples/TestFiles/form1_annots.xfdf +33 -33
- package/samples/TestFiles/form1_data.xfdf +139 -139
- package/samples/TestFiles/my_stream.txt +2310 -2310
- package/samples/TextExtractTest/TextExtractTest.js +286 -286
- package/samples/TextSearchTest/TextSearchTest.js +121 -121
- package/samples/U3DTest/U3DTest.js +1 -1
- package/samples/UndoRedoTest/UndoRedoTest.js +101 -101
- package/samples/UnicodeWriteTest/UnicodeWriteTest.js +173 -173
- package/samples/WebViewerConvertTest/WebViewerConvertTest.js +1 -1
- package/samples/runall.bat +6 -7
- package/samples/runall.sh +15 -14
- package/samples/AddImageTest/RunTest.bat +0 -2
- package/samples/AddImageTest/RunTest.sh +0 -2
- package/samples/AdvancedImagingTest/RunTest.bat +0 -2
- package/samples/AdvancedImagingTest/RunTest.sh +0 -2
- package/samples/AnnotationTest/RunTest.bat +0 -2
- package/samples/AnnotationTest/RunTest.sh +0 -2
- package/samples/BookmarkTest/RunTest.bat +0 -2
- package/samples/BookmarkTest/RunTest.sh +0 -2
- package/samples/CAD2PDFTest/RunTest.bat +0 -2
- package/samples/CAD2PDFTest/RunTest.sh +0 -2
- package/samples/ContentReplacerTest/RunTest.bat +0 -2
- package/samples/ContentReplacerTest/RunTest.sh +0 -2
- package/samples/ConvertTest/RunTest.bat +0 -2
- package/samples/ConvertTest/RunTest.sh +0 -2
- package/samples/DigitalSignaturesTest/RunTest.bat +0 -2
- package/samples/DigitalSignaturesTest/RunTest.sh +0 -2
- package/samples/ElementBuilderTest/RunTest.bat +0 -2
- package/samples/ElementBuilderTest/RunTest.sh +0 -2
- package/samples/ElementEditTest/RunTest.bat +0 -2
- package/samples/ElementEditTest/RunTest.sh +0 -2
- package/samples/ElementReaderAdvTest/RunTest.bat +0 -2
- package/samples/ElementReaderAdvTest/RunTest.sh +0 -2
- package/samples/ElementReaderTest/RunTest.bat +0 -2
- package/samples/ElementReaderTest/RunTest.sh +0 -2
- package/samples/EncTest/RunTest.bat +0 -2
- package/samples/EncTest/RunTest.sh +0 -2
- package/samples/FDFTest/RunTest.bat +0 -2
- package/samples/FDFTest/RunTest.sh +0 -2
- package/samples/HTML2PDFTest/RunTest.bat +0 -2
- package/samples/HTML2PDFTest/RunTest.sh +0 -2
- package/samples/ImageExtractTest/RunTest.bat +0 -2
- package/samples/ImageExtractTest/RunTest.sh +0 -2
- package/samples/ImpositionTest/RunTest.bat +0 -2
- package/samples/ImpositionTest/RunTest.sh +0 -2
- package/samples/InteractiveFormsTest/RunTest.bat +0 -2
- package/samples/InteractiveFormsTest/RunTest.sh +0 -2
- package/samples/JBIG2Test/RunTest.bat +0 -2
- package/samples/JBIG2Test/RunTest.sh +0 -2
- package/samples/LogicalStructureTest/RunTest.bat +0 -2
- package/samples/LogicalStructureTest/RunTest.sh +0 -2
- package/samples/OCRTest/RunTest.bat +0 -2
- package/samples/OCRTest/RunTest.sh +0 -2
- package/samples/OfficeToPDFTest/RunTest.bat +0 -2
- package/samples/OfficeToPDFTest/RunTest.sh +0 -2
- package/samples/OptimizerTest/RunTest.bat +0 -2
- package/samples/OptimizerTest/RunTest.sh +0 -2
- package/samples/PDF2HtmlTest/RunTest.bat +0 -2
- package/samples/PDF2HtmlTest/RunTest.sh +0 -2
- package/samples/PDF2OfficeTest/RunTest.bat +0 -2
- package/samples/PDF2OfficeTest/RunTest.sh +0 -2
- package/samples/PDFATest/RunTest.bat +0 -2
- package/samples/PDFATest/RunTest.sh +0 -2
- package/samples/PDFDocMemoryTest/RunTest.bat +0 -2
- package/samples/PDFDocMemoryTest/RunTest.sh +0 -2
- package/samples/PDFDrawTest/RunTest.bat +0 -2
- package/samples/PDFDrawTest/RunTest.sh +0 -2
- package/samples/PDFLayersTest/RunTest.bat +0 -2
- package/samples/PDFLayersTest/RunTest.sh +0 -2
- package/samples/PDFPackageTest/RunTest.bat +0 -2
- package/samples/PDFPackageTest/RunTest.sh +0 -2
- package/samples/PDFPageTest/RunTest.bat +0 -2
- package/samples/PDFPageTest/RunTest.sh +0 -2
- package/samples/PDFRedactTest/RunTest.bat +0 -2
- package/samples/PDFRedactTest/RunTest.sh +0 -2
- package/samples/PageLabelsTest/RunTest.bat +0 -2
- package/samples/PageLabelsTest/RunTest.sh +0 -2
- package/samples/PatternTest/RunTest.bat +0 -2
- package/samples/PatternTest/RunTest.sh +0 -2
- package/samples/RectTest/RunTest.bat +0 -2
- package/samples/RectTest/RunTest.sh +0 -2
- package/samples/SDFTest/RunTest.bat +0 -2
- package/samples/SDFTest/RunTest.sh +0 -2
- package/samples/StamperTest/RunTest.bat +0 -2
- package/samples/StamperTest/RunTest.sh +0 -2
- package/samples/TextExtractTest/RunTest.bat +0 -2
- package/samples/TextExtractTest/RunTest.sh +0 -2
- package/samples/TextSearchTest/RunTest.bat +0 -2
- package/samples/TextSearchTest/RunTest.sh +0 -2
- package/samples/U3DTest/RunTest.bat +0 -2
- package/samples/U3DTest/RunTest.sh +0 -2
- package/samples/UndoRedoTest/RunTest.bat +0 -2
- package/samples/UndoRedoTest/RunTest.sh +0 -2
- package/samples/UnicodeWriteTest/RunTest.bat +0 -2
- package/samples/UnicodeWriteTest/RunTest.sh +0 -2
- package/samples/WebViewerConvertTest/RunTest.bat +0 -2
- package/samples/WebViewerConvertTest/RunTest.sh +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-
|
|
2
|
+
// Copyright (c) 2001-2022 by PDFTron Systems Inc. All Rights Reserved.
|
|
3
3
|
// Consult legal.txt regarding legal and license information.
|
|
4
4
|
//---------------------------------------------------------------------------------------
|
|
5
5
|
|
|
@@ -29,17 +29,28 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
29
29
|
exports.runHTML2PDFTest = () => {
|
|
30
30
|
const main = async () => {
|
|
31
31
|
const outputPath = '../TestFiles/Output/html2pdf_example';
|
|
32
|
-
const host = '
|
|
33
|
-
const page0 = '
|
|
34
|
-
const page1 = '
|
|
35
|
-
const page2 = '
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// PDFNet library, or in the current working directory, it will be loaded
|
|
40
|
-
// automatically. Otherwise, it must be set manually using HTML2PDF.setModulePath.
|
|
32
|
+
const host = 'https://www.pdftron.com';
|
|
33
|
+
const page0 = '/';
|
|
34
|
+
const page1 = '/support';
|
|
35
|
+
const page2 = '/blog';
|
|
36
|
+
// For HTML2PDF we need to locate the html2pdf module. If placed with the
|
|
37
|
+
// PDFNet library, or in the current working directory, it will be loaded
|
|
38
|
+
// automatically. Otherwise, it must be set manually using HTML2PDF.setModulePath.
|
|
41
39
|
await PDFNet.HTML2PDF.setModulePath('../../lib/');
|
|
42
40
|
|
|
41
|
+
try {
|
|
42
|
+
if(await !PDFNet.HTML2PDF.isModuleAvailable()){
|
|
43
|
+
console.log('Unable to run HTML2PDFTest: PDFTron SDK HTML2PDF module not available.');
|
|
44
|
+
console.log('---------------------------------------------------------------');
|
|
45
|
+
console.log('The HTML2PDF module is an optional add-on, available for download');
|
|
46
|
+
console.log('at https://www.pdftron.com/. If you have already downloaded this');
|
|
47
|
+
console.log('module, ensure that the SDK is able to find the required files');
|
|
48
|
+
console.log('using the HTML2PDF.setModulePath() function.');
|
|
49
|
+
}
|
|
50
|
+
} catch (err) {
|
|
51
|
+
console.log(err);
|
|
52
|
+
}
|
|
53
|
+
|
|
43
54
|
//--------------------------------------------------------------------------------
|
|
44
55
|
// Example 1) Simple conversion of a web page to a PDF doc.
|
|
45
56
|
|
|
@@ -69,16 +80,16 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
69
80
|
|
|
70
81
|
// create the HTML2PDF converter object and modify the output of the PDF pages
|
|
71
82
|
const html2pdf = await PDFNet.HTML2PDF.create();
|
|
72
|
-
html2pdf.setImageQuality(25);
|
|
73
83
|
html2pdf.setPaperSize(PDFNet.PrinterMode.PaperSize.e_11x17);
|
|
74
84
|
|
|
75
85
|
// insert the web page to convert
|
|
76
86
|
html2pdf.insertFromUrl(host.concat(page0));
|
|
87
|
+
|
|
77
88
|
// convert the web page, appending generated PDF pages to doc
|
|
78
89
|
if (await html2pdf.convert(doc)) {
|
|
79
90
|
doc.save(outputPath.concat('_02.pdf'), PDFNet.SDFDoc.SaveOptions.e_linearized);
|
|
80
91
|
} else {
|
|
81
|
-
console.log('
|
|
92
|
+
console.log('Conversion failed. HTTP Code: ' + await html2pdf.getHttpErrorCode());
|
|
82
93
|
console.log(await html2pdf.getLog());
|
|
83
94
|
}
|
|
84
95
|
} catch (err) {
|
|
@@ -86,41 +97,40 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
86
97
|
}
|
|
87
98
|
|
|
88
99
|
//--------------------------------------------------------------------------------
|
|
89
|
-
// Example 3) Convert multiple web pages
|
|
90
|
-
// the first page as a cover page, not to be included with the table of contents outline.
|
|
100
|
+
// Example 3) Convert multiple web pages
|
|
91
101
|
|
|
92
102
|
try {
|
|
93
|
-
//
|
|
94
|
-
const
|
|
95
|
-
cover.setLoadErrorHandling(PDFNet.HTML2PDF.WebPageSettings.ErrorHandling.e_ignore);
|
|
96
|
-
await cover.setIncludeInOutline(false);
|
|
97
|
-
|
|
98
|
-
const html2pdf = await PDFNet.HTML2PDF.create();
|
|
99
|
-
html2pdf.insertFromUrl2(host.concat(page3), cover);
|
|
100
|
-
|
|
101
|
-
// Add a table of contents settings (modifying the settings is optional)
|
|
102
|
-
const toc = await PDFNet.HTML2PDF.TOCSettings.create();
|
|
103
|
-
await toc.setDottedLines(false);
|
|
104
|
-
html2pdf.insertTOC2(toc);
|
|
105
|
-
|
|
106
|
-
// Now add the rest of the web pages, disabling external links and
|
|
107
|
-
// skipping any web pages that fail to load.
|
|
108
|
-
//
|
|
109
|
-
// Note that the order of insertion matters, so these will appear
|
|
110
|
-
// after the cover and table of contents, in the order below.
|
|
111
|
-
const settings = await PDFNet.HTML2PDF.WebPageSettings.create();
|
|
112
|
-
settings.setLoadErrorHandling(PDFNet.HTML2PDF.WebPageSettings.ErrorHandling.e_skip);
|
|
113
|
-
await settings.setExternalLinks(false);
|
|
103
|
+
// convert page 0 into pdf
|
|
104
|
+
const doc = await PDFNet.PDFDoc.create();
|
|
114
105
|
|
|
115
|
-
|
|
116
|
-
html2pdf.insertFromUrl2(host.concat(page1), settings);
|
|
117
|
-
html2pdf.insertFromUrl2(host.concat(page2), settings);
|
|
106
|
+
const converter = await PDFNet.HTML2PDF.create();
|
|
118
107
|
|
|
119
|
-
const
|
|
120
|
-
|
|
108
|
+
const header = '<div style=\'width:15%;margin-left:0.5cm;text-align:left;font-size:10px;color:#0000FF\'><span class=\'date\'></span></div><div style=\'width:70%;direction:rtl;white-space:nowrap;overflow:hidden;text-overflow:clip;text-align:center;font-size:10px;color:#0000FF\'><span>PDFTRON HEADER EXAMPLE</span></div><div style=\'width:15%;margin-right:0.5cm;text-align:right;font-size:10px;color:#0000FF\'><span class=\'pageNumber\'></span> of <span class=\'totalPages\'></span></div>';
|
|
109
|
+
const footer = '<div style=\'width:15%;margin-left:0.5cm;text-align:left;font-size:7px;color:#FF00FF\'><span class=\'date\'></span></div><div style=\'width:70%;direction:rtl;white-space:nowrap;overflow:hidden;text-overflow:clip;text-align:center;font-size:7px;color:#FF00FF\'><span>PDFTRON FOOTER EXAMPLE</span></div><div style=\'width:15%;margin-right:0.5cm;text-align:right;font-size:7px;color:#FF00FF\'><span class=\'pageNumber\'></span> of <span class=\'totalPages\'></span></div>';
|
|
110
|
+
converter.setHeader(header);
|
|
111
|
+
converter.setFooter(footer);
|
|
112
|
+
converter.setMargins('1cm', '2cm', '.5cm', '1.5cm');
|
|
113
|
+
const settings = await PDFNet.HTML2PDF.WebPageSettings.create();
|
|
114
|
+
await settings.setZoom(0.5);
|
|
115
|
+
converter.insertFromUrl2(host.concat(page0), settings);
|
|
116
|
+
const is_conversion_0_successful = await converter.convert(doc);
|
|
117
|
+
|
|
118
|
+
// convert page 1 with the same settings, appending generated PDF pages to doc
|
|
119
|
+
converter.insertFromUrl2(host.concat(page1), settings);
|
|
120
|
+
const is_conversion_1_successful = await converter.convert(doc);
|
|
121
|
+
|
|
122
|
+
// convert page 2 with different settings, appending generated PDF pages to doc
|
|
123
|
+
const another_converter = await PDFNet.HTML2PDF.create();
|
|
124
|
+
another_converter.setLandscape(true);
|
|
125
|
+
const another_settings = await PDFNet.HTML2PDF.WebPageSettings.create();
|
|
126
|
+
another_settings.setPrintBackground(false);
|
|
127
|
+
another_converter.insertFromUrl2(host.concat(page2), another_settings);
|
|
128
|
+
const is_conversion_2_successful = await another_converter.convert(doc);
|
|
129
|
+
|
|
130
|
+
if(is_conversion_0_successful && is_conversion_1_successful && is_conversion_2_successful) {
|
|
121
131
|
doc.save(outputPath.concat('_03.pdf'), PDFNet.SDFDoc.SaveOptions.e_linearized);
|
|
122
132
|
} else {
|
|
123
|
-
console.log('
|
|
133
|
+
console.log('Conversion failed. HTTP Code: ' + await html2pdf.getHttpErrorCode());
|
|
124
134
|
console.log(await html2pdf.getLog());
|
|
125
135
|
}
|
|
126
136
|
} catch (err) {
|
|
@@ -133,13 +143,13 @@ const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
|
133
143
|
try {
|
|
134
144
|
const html2pdf = await PDFNet.HTML2PDF.create();
|
|
135
145
|
const doc = await PDFNet.PDFDoc.create();
|
|
136
|
-
const html = '<html><body><h1>Heading</h1><p>Paragraph.</p></body></html>'
|
|
146
|
+
const html = '<html><body><h1>Heading</h1><p>Paragraph.</p></body></html>';
|
|
137
147
|
|
|
138
148
|
html2pdf.insertFromHtmlString(html);
|
|
139
149
|
if (await html2pdf.convert(doc)) {
|
|
140
150
|
doc.save(outputPath.concat('_04.pdf'), PDFNet.SDFDoc.SaveOptions.e_linearized);
|
|
141
151
|
} else {
|
|
142
|
-
console.log('
|
|
152
|
+
console.log('Conversion failed. HTTP Code: ' + await html2pdf.getHttpErrorCode());
|
|
143
153
|
console.log(await html2pdf.getLog());
|
|
144
154
|
}
|
|
145
155
|
} catch (err) {
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
//---------------------------------------------------------------------------------------
|
|
2
|
+
// Copyright (c) 2001-2022 by PDFTron Systems Inc. All Rights Reserved.
|
|
3
|
+
// Consult legal.txt regarding legal and license information.
|
|
4
|
+
//---------------------------------------------------------------------------------------
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const { PDFNet } = require('@pdftron/pdfnet-node');
|
|
8
|
+
const PDFTronLicense = require('../LicenseKey/LicenseKey');
|
|
9
|
+
|
|
10
|
+
// This sample illustrates the basic text highlight capabilities of PDFNet.
|
|
11
|
+
// It simulates a full-text search engine that finds all occurrences of the word 'Federal'.
|
|
12
|
+
// It then highlights those words on the page.
|
|
13
|
+
//
|
|
14
|
+
// Note: The TextSearch class is the preferred solution for searching text within a single
|
|
15
|
+
// PDF file. TextExtractor provides search highlighting capabilities where a large number
|
|
16
|
+
// of documents are indexed using a 3rd party search engine.
|
|
17
|
+
((exports) => {
|
|
18
|
+
|
|
19
|
+
exports.runHighlightsTest = async () => {
|
|
20
|
+
const main = async () => {
|
|
21
|
+
// eslint-disable-next-line no-unused-vars
|
|
22
|
+
let ret = 0;
|
|
23
|
+
|
|
24
|
+
// Relative path to the folder containing test files.
|
|
25
|
+
const inputPath = '../TestFiles/';
|
|
26
|
+
const outputPath = '../TestFiles/Output/';
|
|
27
|
+
const inputFilename = 'paragraphs_and_tables.pdf';
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
await PDFNet.startDeallocateStack();
|
|
31
|
+
const doc = await PDFNet.PDFDoc.createFromFilePath(inputPath + inputFilename);
|
|
32
|
+
doc.initSecurityHandler();
|
|
33
|
+
|
|
34
|
+
const page = await doc.getPage(1);
|
|
35
|
+
|
|
36
|
+
if (page.id === '0') {
|
|
37
|
+
console.log('Page not found.');
|
|
38
|
+
return 1;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const txt = await PDFNet.TextExtractor.create();
|
|
42
|
+
txt.begin(page);
|
|
43
|
+
|
|
44
|
+
// Do not dehyphenate; that would interfere with character offsets
|
|
45
|
+
const dehyphen = false;
|
|
46
|
+
// Retrieve the page text
|
|
47
|
+
const pageText = await txt.getAsText(dehyphen);
|
|
48
|
+
|
|
49
|
+
// Simulating a full-text search engine that finds all occurrences of the word 'Federal'.
|
|
50
|
+
// In a real application, plug in your own search engine here.
|
|
51
|
+
const searchText = 'Federal';
|
|
52
|
+
let charRanges = [];
|
|
53
|
+
let ofs = pageText.indexOf(searchText);
|
|
54
|
+
while (ofs >= 0) {
|
|
55
|
+
const range = { index: ofs, length: searchText.length };
|
|
56
|
+
charRanges.push(range); // character offset + length
|
|
57
|
+
ofs = pageText.indexOf(searchText, ofs + 1);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Retrieve Highlights object and apply annotations to the page
|
|
61
|
+
const hlts = await txt.getHighlights(charRanges);
|
|
62
|
+
await hlts.begin(doc);
|
|
63
|
+
while ((await hlts.hasNext())) {
|
|
64
|
+
const curPage = await doc.getPage((await hlts.getCurrentPageNumber()));
|
|
65
|
+
const quadArr = await hlts.getCurrentQuads();
|
|
66
|
+
for (let i = 0; i < quadArr.length; ++i) {
|
|
67
|
+
const currQuad = quadArr[i];
|
|
68
|
+
const x1 = Math.min(Math.min(Math.min(currQuad.p1x, currQuad.p2x), currQuad.p3x), currQuad.p4x);
|
|
69
|
+
const x2 = Math.max(Math.max(Math.max(currQuad.p1x, currQuad.p2x), currQuad.p3x), currQuad.p4x);
|
|
70
|
+
const y1 = Math.min(Math.min(Math.min(currQuad.p1y, currQuad.p2y), currQuad.p3y), currQuad.p4y);
|
|
71
|
+
const y2 = Math.max(Math.max(Math.max(currQuad.p1y, currQuad.p2y), currQuad.p3y), currQuad.p4y);
|
|
72
|
+
|
|
73
|
+
const highlight = await PDFNet.HighlightAnnot.create(doc, (await PDFNet.Rect.init(x1, y1, x2, y2)));
|
|
74
|
+
await highlight.refreshAppearance();
|
|
75
|
+
await curPage.annotPushBack(highlight);
|
|
76
|
+
|
|
77
|
+
console.log('[' + x1.toFixed(2) + ', ' + y1.toFixed(2) + ', ' + x2.toFixed(2) + ', ' + y2.toFixed(2) + ']');
|
|
78
|
+
}
|
|
79
|
+
hlts.next();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Output highlighted PDF doc
|
|
83
|
+
await doc.save(outputPath + 'search_highlights.pdf', PDFNet.SDFDoc.SaveOptions.e_linearized);
|
|
84
|
+
|
|
85
|
+
await PDFNet.endDeallocateStack();
|
|
86
|
+
} catch (err) {
|
|
87
|
+
console.log(err);
|
|
88
|
+
console.log(err.stack);
|
|
89
|
+
ret = 1;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) { console.log('Error: ' + JSON.stringify(error)); }).then(function () { return PDFNet.shutdown(); });
|
|
93
|
+
};
|
|
94
|
+
exports.runHighlightsTest();
|
|
95
|
+
})(exports);
|
|
96
|
+
// eslint-disable-next-line spaced-comment
|
|
97
|
+
//# sourceURL=HighlightsTest.js
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-
|
|
2
|
+
// Copyright (c) 2001-2022 by PDFTron Systems Inc. All Rights Reserved.
|
|
3
3
|
// Consult legal.txt regarding legal and license information.
|
|
4
4
|
//---------------------------------------------------------------------------------------
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-
|
|
2
|
+
// Copyright (c) 2001-2022 by PDFTron Systems Inc. All Rights Reserved.
|
|
3
3
|
// Consult legal.txt regarding legal and license information.
|
|
4
4
|
//---------------------------------------------------------------------------------------
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-
|
|
2
|
+
// Copyright (c) 2001-2022 by PDFTron Systems Inc. All Rights Reserved.
|
|
3
3
|
// Consult legal.txt regarding legal and license information.
|
|
4
4
|
//---------------------------------------------------------------------------------------
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-
|
|
2
|
+
// Copyright (c) 2001-2022 by PDFTron Systems Inc. All Rights Reserved.
|
|
3
3
|
// Consult legal.txt regarding legal and license information.
|
|
4
4
|
//---------------------------------------------------------------------------------------
|
|
5
5
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
//---------------------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2001-2021 by PDFTron Systems Inc. All Rights Reserved.
|
|
3
|
-
// Consult legal.txt regarding legal and license information.
|
|
4
|
-
//---------------------------------------------------------------------------------------
|
|
5
|
-
|
|
6
|
-
//"Enter your key here. If you don't have it, please go to https://www.pdftron.com/pws/get-key to obtain a demo license or https://www.pdftron.com/form/contact-sales to obtain a production key.
|
|
7
|
-
const LicenseKey = 'YOUR_PDFTRON_LICENSE_KEY';
|
|
8
|
-
if(LicenseKey == 'YOUR_PDFTRON_LICENSE_KEY'){
|
|
9
|
-
throw ('Please enter your license key by replacing \'YOUR_PDFTRON_LICENSE_KEY\' that is assigned to the LicenseKey variable in Samples/LicenseKey/LicenseKey.js. If you do not have a license key, please go to https://www.pdftron.com/pws/get-key to obtain a demo license or https://www.pdftron.com/form/contact-sales to obtain a production key.');
|
|
10
|
-
}
|
|
11
|
-
exports.Key = LicenseKey;
|
|
1
|
+
//---------------------------------------------------------------------------------------
|
|
2
|
+
// Copyright (c) 2001-2021 by PDFTron Systems Inc. All Rights Reserved.
|
|
3
|
+
// Consult legal.txt regarding legal and license information.
|
|
4
|
+
//---------------------------------------------------------------------------------------
|
|
5
|
+
|
|
6
|
+
//"Enter your key here. If you don't have it, please go to https://www.pdftron.com/pws/get-key to obtain a demo license or https://www.pdftron.com/form/contact-sales to obtain a production key.
|
|
7
|
+
const LicenseKey = 'YOUR_PDFTRON_LICENSE_KEY';
|
|
8
|
+
if(LicenseKey == 'YOUR_PDFTRON_LICENSE_KEY'){
|
|
9
|
+
throw ('Please enter your license key by replacing \'YOUR_PDFTRON_LICENSE_KEY\' that is assigned to the LicenseKey variable in Samples/LicenseKey/LicenseKey.js. If you do not have a license key, please go to https://www.pdftron.com/pws/get-key to obtain a demo license or https://www.pdftron.com/form/contact-sales to obtain a production key.');
|
|
10
|
+
}
|
|
11
|
+
exports.Key = LicenseKey;
|