@pdftron/pdfnet-node-samples 10.7.0 → 10.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/package.json +21 -20
  2. package/readme.md +12 -12
  3. package/samples/AddImageTest/AddImageTest.js +115 -115
  4. package/samples/AdvancedImagingTest/AdvancedImagingTest.js +78 -78
  5. package/samples/AnnotationTest/AnnotationTest.js +641 -641
  6. package/samples/BookmarkTest/BookmarkTest.js +219 -219
  7. package/samples/CAD2PDFTest/CAD2PDFTest.js +79 -79
  8. package/samples/ContentReplacerTest/ContentReplacerTest.js +75 -75
  9. package/samples/ConvertPrintTest/ConvertPrintTest.js +153 -153
  10. package/samples/ConvertTest/ConvertTest.js +203 -203
  11. package/samples/DataExtractionTest/DataExtractionTest.js +214 -214
  12. package/samples/DigitalSignaturesTest/DigitalSignaturesTest.js +526 -526
  13. package/samples/DocumentCreationTest/DocumentCreationTest.js +409 -409
  14. package/samples/ElementBuilderTest/ElementBuilderTest.js +513 -513
  15. package/samples/ElementEditTest/ElementEditTest.js +110 -110
  16. package/samples/ElementReaderAdvTest/ElementReaderAdvTest.js +305 -305
  17. package/samples/ElementReaderTest/ElementReaderTest.js +77 -77
  18. package/samples/EncTest/EncTest.js +175 -175
  19. package/samples/FDFTest/FDFTest.js +218 -218
  20. package/samples/HTML2PDFTest/HTML2PDFTest.js +164 -164
  21. package/samples/HighlightsTest/HighlightsTest.js +97 -97
  22. package/samples/ImageExtractTest/ImageExtractTest.js +129 -129
  23. package/samples/ImpositionTest/ImpositionTest.js +86 -86
  24. package/samples/InteractiveFormsTest/InteractiveFormsTest.js +381 -381
  25. package/samples/JBIG2Test/JBIG2Test.js +88 -88
  26. package/samples/LicenseKey/LicenseKey.js +11 -11
  27. package/samples/LogicalStructureTest/LogicalStructureTest.js +250 -250
  28. package/samples/OCRTest/OCRTest.js +235 -235
  29. package/samples/OfficeTemplateTest/OfficeTemplateTest.js +79 -79
  30. package/samples/OfficeToPDFTest/OfficeToPDFTest.js +125 -125
  31. package/samples/OptimizerTest/OptimizerTest.js +191 -191
  32. package/samples/PDF2HtmlTest/PDF2HtmlTest.js +123 -123
  33. package/samples/PDF2OfficeTest/PDF2OfficeTest.js +158 -158
  34. package/samples/PDFATest/PDFATest.js +85 -85
  35. package/samples/PDFDocMemoryTest/PDFDocMemoryTest.js +84 -84
  36. package/samples/PDFDrawTest/PDFDrawTest.js +305 -305
  37. package/samples/PDFLayersTest/PDFLayersTest.js +294 -294
  38. package/samples/PDFPackageTest/PDFPackageTest.js +111 -111
  39. package/samples/PDFPageTest/PDFPageTest.js +189 -189
  40. package/samples/PDFRedactTest/PDFRedactTest.js +74 -74
  41. package/samples/PageLabelsTest/PageLabelsTest.js +138 -138
  42. package/samples/PatternTest/PatternTest.js +226 -226
  43. package/samples/RectTest/RectTest.js +40 -40
  44. package/samples/SDFTest/SDFTest.js +87 -87
  45. package/samples/StamperTest/StamperTest.js +255 -255
  46. package/samples/TestFiles/Misc-Fixed.pfa +1166 -1166
  47. package/samples/TestFiles/SHA-2 Root USERTrust RSA CA Sectigo timestamping.crt +34 -34
  48. package/samples/TestFiles/form1_annots.xfdf +33 -33
  49. package/samples/TestFiles/form1_data.xfdf +139 -139
  50. package/samples/TestFiles/my_stream.txt +2310 -2310
  51. package/samples/TestFiles/tiger.svg +378 -378
  52. package/samples/TextExtractTest/TextExtractTest.js +286 -286
  53. package/samples/TextSearchTest/TextSearchTest.js +121 -121
  54. package/samples/U3DTest/U3DTest.js +104 -104
  55. package/samples/UndoRedoTest/UndoRedoTest.js +101 -101
  56. package/samples/UnicodeWriteTest/UnicodeWriteTest.js +173 -173
  57. package/samples/WebViewerConvertTest/WebViewerConvertTest.js +135 -135
  58. package/samples/runall.bat +12 -12
  59. package/samples/runall.sh +15 -15
@@ -1,227 +1,227 @@
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.runPatternTest = () => {
13
- const createTilingPattern = async (doc) => {
14
- const writer = await PDFNet.ElementWriter.create();
15
- const eb = await PDFNet.ElementBuilder.create();
16
-
17
- // Create a new pattern content stream - a heart. ------------
18
- writer.begin(doc);
19
- eb.pathBegin();
20
- eb.moveTo(0, 0);
21
- eb.curveTo(500, 500, 125, 625, 0, 500);
22
- eb.curveTo(-125, 625, -500, 500, 0, 0);
23
- const heart = await eb.pathEnd();
24
- heart.setPathFill(true);
25
-
26
- // Set heart color to red.
27
- const gstate = await heart.getGState();
28
- gstate.setFillColorSpace(await PDFNet.ColorSpace.createDeviceRGB());
29
- gstate.setStrokeColorWithColorPt(await PDFNet.ColorPt.init(1, 0, 0));
30
- writer.writeElement(heart);
31
-
32
- const patternDict = await writer.end();
33
-
34
- // Initialize pattern dictionary. For details on what each parameter represents please
35
- // refer to Table 4.22 (Section '4.6.2 Tiling Patterns') in PDF Reference Manual.
36
- patternDict.putName('Type', 'Pattern');
37
- patternDict.putNumber('PatternType', 1);
38
-
39
- // TilingType - Constant spacing.
40
- patternDict.putNumber('TilingType', 1);
41
-
42
- // This is a Type1 pattern - A colored tiling pattern.
43
- patternDict.putNumber('PaintType', 1);
44
-
45
- // Set bounding box
46
- patternDict.putRect('BBox', -253, 0, 253, 545);
47
-
48
- // Create and set the matrix
49
- const pattern_mtx = await PDFNet.Matrix2D.create(0.04, 0, 0, 0.04, 0, 0);
50
- patternDict.putMatrix('Matrix', pattern_mtx);
51
-
52
- // Set the desired horizontal and vertical spacing between pattern cells,
53
- // measured in the pattern coordinate system.
54
- patternDict.putNumber('XStep', 1000);
55
- await patternDict.putNumber('YStep', 1000);
56
-
57
- return patternDict; // finished creating the Pattern resource
58
- }
59
-
60
- const createImageTilingPattern = async (doc) => {
61
- const writer = await PDFNet.ElementWriter.create();
62
- const eb = await PDFNet.ElementBuilder.create();
63
-
64
- // Create a new pattern content stream - a single bitmap object ----------
65
- writer.begin(doc);
66
- const image = await PDFNet.Image.createFromFile(doc, '../TestFiles/dice.jpg');
67
- const imgElement = await eb.createImageScaled(image, 0, 0, await image.getImageWidth(), await image.getImageHeight());
68
- writer.writePlacedElement(imgElement);
69
-
70
- const patternDict = await writer.end();
71
-
72
- // Initialize pattern dictionary. For details on what each parameter represents please
73
- // refer to Table 4.22 (Section '4.6.2 Tiling Patterns') in PDF Reference Manual.
74
- patternDict.putName('Type', 'Pattern');
75
- patternDict.putNumber('PatternType', 1);
76
-
77
- // TilingType - Constant spacing.
78
- patternDict.putNumber('TilingType', 1);
79
-
80
- // This is a Type1 pattern - A colored tiling pattern.
81
- patternDict.putNumber('PaintType', 1);
82
-
83
- // Set bounding box
84
- patternDict.putRect('BBox', -253, 0, 253, 545);
85
-
86
- // Create and set the matrix
87
- const pattern_mtx = await PDFNet.Matrix2D.create(0.3, 0, 0, 0.3, 0, 0);
88
- patternDict.putMatrix('Matrix', pattern_mtx);
89
-
90
- // Set the desired horizontal and vertical spacing between pattern cells,
91
- // measured in the pattern coordinate system.
92
- patternDict.putNumber('XStep', 300);
93
- await patternDict.putNumber('YStep', 300);
94
-
95
- return patternDict; // finished creating the Pattern resource
96
- }
97
-
98
- const createAxialShading = async (doc) => {
99
- // Create a new Shading object ------------
100
- const patternDict = await doc.createIndirectDict();
101
-
102
- // Initialize pattern dictionary. For details on what each parameter represents
103
- // please refer to Tables 4.30 and 4.26 in PDF Reference Manual
104
- patternDict.putName('Type', 'Pattern');
105
- patternDict.putNumber('PatternType', 2); // 2 stands for shading
106
-
107
- const shadingDict = await patternDict.putDict('Shading');
108
- shadingDict.putNumber('ShadingType', 2);
109
- shadingDict.putName('ColorSpace', 'DeviceCMYK');
110
-
111
- // pass the coordinates of the axial shading to the output
112
- const shadingCoords = await shadingDict.putArray('Coords');
113
- shadingCoords.pushBackNumber(0);
114
- shadingCoords.pushBackNumber(0);
115
- shadingCoords.pushBackNumber(612);
116
- shadingCoords.pushBackNumber(794);
117
-
118
- // pass the function to the axial shading
119
- const func = await shadingDict.putDict('Function');
120
- const C0 = await func.putArray('C0');
121
- C0.pushBackNumber(1);
122
- C0.pushBackNumber(0);
123
- C0.pushBackNumber(0);
124
- await C0.pushBackNumber(0);
125
-
126
- const C1 = await func.putArray('C1');
127
- C1.pushBackNumber(0);
128
- C1.pushBackNumber(1);
129
- C1.pushBackNumber(0);
130
- await C1.pushBackNumber(0);
131
-
132
- const domain = await func.putArray('Domain');
133
- domain.pushBackNumber(0);
134
- await domain.pushBackNumber(1);
135
-
136
- func.putNumber('FunctionType', 2);
137
- await func.putNumber('N', 1);
138
-
139
- return patternDict;
140
- }
141
-
142
- const main = async () => {
143
- try {
144
- const doc = await PDFNet.PDFDoc.create();
145
- const writer = await PDFNet.ElementWriter.create();
146
- var eb = await PDFNet.ElementBuilder.create();
147
-
148
- // The following sample illustrates how to create and use tiling patterns
149
- var page = await doc.pageCreate();
150
- writer.beginOnPage(page);
151
-
152
- var element = await eb.createTextBeginWithFont(await PDFNet.Font.createAndEmbed(doc, PDFNet.Font.StandardType1Font.e_times_bold), 1);
153
- writer.writeElement(element); // Begin the text block
154
-
155
- const data = 'G';
156
- element = await eb.createNewTextRun(data);
157
- element.setTextMatrixEntries(720, 0, 0, 720, 20, 240);
158
- var gs = await element.getGState();
159
- gs.setTextRenderMode(PDFNet.GState.TextRenderingMode.e_fill_stroke_text);
160
- gs.setLineWidth(4);
161
-
162
- // Set the fill color space to the Pattern color space.
163
- gs.setFillColorSpace(await PDFNet.ColorSpace.createPattern());
164
- var patterColor = await PDFNet.PatternColor.create(await createTilingPattern(doc));
165
- gs.setFillColorWithPattern(patterColor);
166
-
167
- writer.writeElement(element);
168
- writer.writeElement(await eb.createTextEnd()); // Finish the text block
169
-
170
- writer.end(); // Save the page
171
- doc.pagePushBack(page);
172
- //-----------------------------------------------
173
-
174
- /// The following sample illustrates how to create and use image tiling pattern
175
- page = await doc.pageCreate();
176
- writer.beginOnPage(page);
177
-
178
- eb.reset();
179
- element = await eb.createRect(0, 0, 612, 794);
180
-
181
- // Set the fill color space to the Pattern color space.
182
- gs = await element.getGState();
183
- gs.setFillColorSpace(await PDFNet.ColorSpace.createPattern());
184
- patterColor = await PDFNet.PatternColor.create(await createImageTilingPattern(doc));
185
- gs.setFillColorWithPattern(patterColor);
186
- element.setPathFill(true);
187
-
188
- writer.writeElement(element);
189
-
190
- await writer.end(); // Save the page
191
- doc.pagePushBack(page);
192
- //-----------------------------------------------
193
-
194
- /// The following sample illustrates how to create and use PDF shadings
195
- page = await doc.pageCreate();
196
- writer.beginOnPage(page);
197
-
198
- eb.reset();
199
- element = await eb.createRect(0, 0, 612, 794);
200
-
201
- // Set the fill color space to the Pattern color space.
202
- gs = await element.getGState();
203
- gs.setFillColorSpace(await PDFNet.ColorSpace.createPattern());
204
- patterColor = await PDFNet.PatternColor.create(await createAxialShading(doc));
205
- gs.setFillColorWithPattern(patterColor);
206
- element.setPathFill(true);
207
-
208
- writer.writeElement(element);
209
-
210
- await writer.end(); // Save the page
211
- doc.pagePushBack(page);
212
- //-----------------------------------------------
213
-
214
- await doc.save('../TestFiles/Output/patterns.pdf', PDFNet.SDFDoc.SaveOptions.e_remove_unused);
215
- console.log('Done. Result saved in patterns.pdf...');
216
- } catch (err) {
217
- console.log(err);
218
- }
219
- }
220
- PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error) {
221
- console.log('Error: ' + JSON.stringify(error));
222
- }).then(function(){ return PDFNet.shutdown(); });
223
- };
224
- exports.runPatternTest();
225
- })(exports);
226
- // eslint-disable-next-line spaced-comment
1
+ //---------------------------------------------------------------------------------------
2
+ // Copyright (c) 2001-2024 by Apryse Software Inc. All Rights Reserved.
3
+ // Consult legal.txt regarding legal and license information.
4
+ //---------------------------------------------------------------------------------------
5
+
6
+ const { PDFNet } = require('@pdftron/pdfnet-node');
7
+ const PDFTronLicense = require('../LicenseKey/LicenseKey');
8
+
9
+ ((exports) => {
10
+ 'use strict';
11
+
12
+ exports.runPatternTest = () => {
13
+ const createTilingPattern = async (doc) => {
14
+ const writer = await PDFNet.ElementWriter.create();
15
+ const eb = await PDFNet.ElementBuilder.create();
16
+
17
+ // Create a new pattern content stream - a heart. ------------
18
+ writer.begin(doc);
19
+ eb.pathBegin();
20
+ eb.moveTo(0, 0);
21
+ eb.curveTo(500, 500, 125, 625, 0, 500);
22
+ eb.curveTo(-125, 625, -500, 500, 0, 0);
23
+ const heart = await eb.pathEnd();
24
+ heart.setPathFill(true);
25
+
26
+ // Set heart color to red.
27
+ const gstate = await heart.getGState();
28
+ gstate.setFillColorSpace(await PDFNet.ColorSpace.createDeviceRGB());
29
+ gstate.setStrokeColorWithColorPt(await PDFNet.ColorPt.init(1, 0, 0));
30
+ writer.writeElement(heart);
31
+
32
+ const patternDict = await writer.end();
33
+
34
+ // Initialize pattern dictionary. For details on what each parameter represents please
35
+ // refer to Table 4.22 (Section '4.6.2 Tiling Patterns') in PDF Reference Manual.
36
+ patternDict.putName('Type', 'Pattern');
37
+ patternDict.putNumber('PatternType', 1);
38
+
39
+ // TilingType - Constant spacing.
40
+ patternDict.putNumber('TilingType', 1);
41
+
42
+ // This is a Type1 pattern - A colored tiling pattern.
43
+ patternDict.putNumber('PaintType', 1);
44
+
45
+ // Set bounding box
46
+ patternDict.putRect('BBox', -253, 0, 253, 545);
47
+
48
+ // Create and set the matrix
49
+ const pattern_mtx = await PDFNet.Matrix2D.create(0.04, 0, 0, 0.04, 0, 0);
50
+ patternDict.putMatrix('Matrix', pattern_mtx);
51
+
52
+ // Set the desired horizontal and vertical spacing between pattern cells,
53
+ // measured in the pattern coordinate system.
54
+ patternDict.putNumber('XStep', 1000);
55
+ await patternDict.putNumber('YStep', 1000);
56
+
57
+ return patternDict; // finished creating the Pattern resource
58
+ }
59
+
60
+ const createImageTilingPattern = async (doc) => {
61
+ const writer = await PDFNet.ElementWriter.create();
62
+ const eb = await PDFNet.ElementBuilder.create();
63
+
64
+ // Create a new pattern content stream - a single bitmap object ----------
65
+ writer.begin(doc);
66
+ const image = await PDFNet.Image.createFromFile(doc, '../TestFiles/dice.jpg');
67
+ const imgElement = await eb.createImageScaled(image, 0, 0, await image.getImageWidth(), await image.getImageHeight());
68
+ writer.writePlacedElement(imgElement);
69
+
70
+ const patternDict = await writer.end();
71
+
72
+ // Initialize pattern dictionary. For details on what each parameter represents please
73
+ // refer to Table 4.22 (Section '4.6.2 Tiling Patterns') in PDF Reference Manual.
74
+ patternDict.putName('Type', 'Pattern');
75
+ patternDict.putNumber('PatternType', 1);
76
+
77
+ // TilingType - Constant spacing.
78
+ patternDict.putNumber('TilingType', 1);
79
+
80
+ // This is a Type1 pattern - A colored tiling pattern.
81
+ patternDict.putNumber('PaintType', 1);
82
+
83
+ // Set bounding box
84
+ patternDict.putRect('BBox', -253, 0, 253, 545);
85
+
86
+ // Create and set the matrix
87
+ const pattern_mtx = await PDFNet.Matrix2D.create(0.3, 0, 0, 0.3, 0, 0);
88
+ patternDict.putMatrix('Matrix', pattern_mtx);
89
+
90
+ // Set the desired horizontal and vertical spacing between pattern cells,
91
+ // measured in the pattern coordinate system.
92
+ patternDict.putNumber('XStep', 300);
93
+ await patternDict.putNumber('YStep', 300);
94
+
95
+ return patternDict; // finished creating the Pattern resource
96
+ }
97
+
98
+ const createAxialShading = async (doc) => {
99
+ // Create a new Shading object ------------
100
+ const patternDict = await doc.createIndirectDict();
101
+
102
+ // Initialize pattern dictionary. For details on what each parameter represents
103
+ // please refer to Tables 4.30 and 4.26 in PDF Reference Manual
104
+ patternDict.putName('Type', 'Pattern');
105
+ patternDict.putNumber('PatternType', 2); // 2 stands for shading
106
+
107
+ const shadingDict = await patternDict.putDict('Shading');
108
+ shadingDict.putNumber('ShadingType', 2);
109
+ shadingDict.putName('ColorSpace', 'DeviceCMYK');
110
+
111
+ // pass the coordinates of the axial shading to the output
112
+ const shadingCoords = await shadingDict.putArray('Coords');
113
+ shadingCoords.pushBackNumber(0);
114
+ shadingCoords.pushBackNumber(0);
115
+ shadingCoords.pushBackNumber(612);
116
+ shadingCoords.pushBackNumber(794);
117
+
118
+ // pass the function to the axial shading
119
+ const func = await shadingDict.putDict('Function');
120
+ const C0 = await func.putArray('C0');
121
+ C0.pushBackNumber(1);
122
+ C0.pushBackNumber(0);
123
+ C0.pushBackNumber(0);
124
+ await C0.pushBackNumber(0);
125
+
126
+ const C1 = await func.putArray('C1');
127
+ C1.pushBackNumber(0);
128
+ C1.pushBackNumber(1);
129
+ C1.pushBackNumber(0);
130
+ await C1.pushBackNumber(0);
131
+
132
+ const domain = await func.putArray('Domain');
133
+ domain.pushBackNumber(0);
134
+ await domain.pushBackNumber(1);
135
+
136
+ func.putNumber('FunctionType', 2);
137
+ await func.putNumber('N', 1);
138
+
139
+ return patternDict;
140
+ }
141
+
142
+ const main = async () => {
143
+ try {
144
+ const doc = await PDFNet.PDFDoc.create();
145
+ const writer = await PDFNet.ElementWriter.create();
146
+ var eb = await PDFNet.ElementBuilder.create();
147
+
148
+ // The following sample illustrates how to create and use tiling patterns
149
+ var page = await doc.pageCreate();
150
+ writer.beginOnPage(page);
151
+
152
+ var element = await eb.createTextBeginWithFont(await PDFNet.Font.createAndEmbed(doc, PDFNet.Font.StandardType1Font.e_times_bold), 1);
153
+ writer.writeElement(element); // Begin the text block
154
+
155
+ const data = 'G';
156
+ element = await eb.createNewTextRun(data);
157
+ element.setTextMatrixEntries(720, 0, 0, 720, 20, 240);
158
+ var gs = await element.getGState();
159
+ gs.setTextRenderMode(PDFNet.GState.TextRenderingMode.e_fill_stroke_text);
160
+ gs.setLineWidth(4);
161
+
162
+ // Set the fill color space to the Pattern color space.
163
+ gs.setFillColorSpace(await PDFNet.ColorSpace.createPattern());
164
+ var patterColor = await PDFNet.PatternColor.create(await createTilingPattern(doc));
165
+ gs.setFillColorWithPattern(patterColor);
166
+
167
+ writer.writeElement(element);
168
+ writer.writeElement(await eb.createTextEnd()); // Finish the text block
169
+
170
+ writer.end(); // Save the page
171
+ doc.pagePushBack(page);
172
+ //-----------------------------------------------
173
+
174
+ /// The following sample illustrates how to create and use image tiling pattern
175
+ page = await doc.pageCreate();
176
+ writer.beginOnPage(page);
177
+
178
+ eb.reset();
179
+ element = await eb.createRect(0, 0, 612, 794);
180
+
181
+ // Set the fill color space to the Pattern color space.
182
+ gs = await element.getGState();
183
+ gs.setFillColorSpace(await PDFNet.ColorSpace.createPattern());
184
+ patterColor = await PDFNet.PatternColor.create(await createImageTilingPattern(doc));
185
+ gs.setFillColorWithPattern(patterColor);
186
+ element.setPathFill(true);
187
+
188
+ writer.writeElement(element);
189
+
190
+ await writer.end(); // Save the page
191
+ doc.pagePushBack(page);
192
+ //-----------------------------------------------
193
+
194
+ /// The following sample illustrates how to create and use PDF shadings
195
+ page = await doc.pageCreate();
196
+ writer.beginOnPage(page);
197
+
198
+ eb.reset();
199
+ element = await eb.createRect(0, 0, 612, 794);
200
+
201
+ // Set the fill color space to the Pattern color space.
202
+ gs = await element.getGState();
203
+ gs.setFillColorSpace(await PDFNet.ColorSpace.createPattern());
204
+ patterColor = await PDFNet.PatternColor.create(await createAxialShading(doc));
205
+ gs.setFillColorWithPattern(patterColor);
206
+ element.setPathFill(true);
207
+
208
+ writer.writeElement(element);
209
+
210
+ await writer.end(); // Save the page
211
+ doc.pagePushBack(page);
212
+ //-----------------------------------------------
213
+
214
+ await doc.save('../TestFiles/Output/patterns.pdf', PDFNet.SDFDoc.SaveOptions.e_remove_unused);
215
+ console.log('Done. Result saved in patterns.pdf...');
216
+ } catch (err) {
217
+ console.log(err);
218
+ }
219
+ }
220
+ PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error) {
221
+ console.log('Error: ' + JSON.stringify(error));
222
+ }).then(function(){ return PDFNet.shutdown(); });
223
+ };
224
+ exports.runPatternTest();
225
+ })(exports);
226
+ // eslint-disable-next-line spaced-comment
227
227
  //# sourceURL=PatternTest.js
@@ -1,41 +1,41 @@
1
- //---------------------------------------------------------------------------------------
2
- // Copyright (c) 2001-2024 by Apryse Software Inc. All Rights Reserved.
3
- // Consult legal.txt regarding legal and license information.
4
- //---------------------------------------------------------------------------------------
5
-
6
-
7
- const { PDFNet } = require('@pdftron/pdfnet-node');
8
- const PDFTronLicense = require('../LicenseKey/LicenseKey');
9
-
10
- ((exports) => {
11
-
12
- exports.runRectTest = () => {
13
-
14
- const main = async() => {
15
- try {
16
- console.log('_______________________________________________');
17
- console.log('Opening the input pdf...');
18
-
19
- const inputPath = '../TestFiles/';
20
- const doc = await PDFNet.PDFDoc.createFromFilePath(inputPath + 'tiger.pdf');
21
- doc.initSecurityHandler();
22
-
23
- const pgItr1 = await doc.getPageIterator();
24
- const mediaBox = await (await pgItr1.current()).getMediaBox();
25
- mediaBox.x1 -= 200; // translate page 200 units left(1 uint = 1/72 inch)
26
- mediaBox.x2 -= 200;
27
-
28
- await mediaBox.update();
29
-
30
- await doc.save(inputPath + 'Output/tiger_shift.pdf', 0);
31
- console.log('Done. Result saved in tiger_shift...');
32
- } catch (err) {
33
- console.log(err);
34
- }
35
- };
36
- PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error){console.log('Error: ' + JSON.stringify(error));}).then(function(){return PDFNet.shutdown();});
37
- };
38
- exports.runRectTest();
39
- })(exports);
40
- // eslint-disable-next-line spaced-comment
1
+ //---------------------------------------------------------------------------------------
2
+ // Copyright (c) 2001-2024 by Apryse Software Inc. All Rights Reserved.
3
+ // Consult legal.txt regarding legal and license information.
4
+ //---------------------------------------------------------------------------------------
5
+
6
+
7
+ const { PDFNet } = require('@pdftron/pdfnet-node');
8
+ const PDFTronLicense = require('../LicenseKey/LicenseKey');
9
+
10
+ ((exports) => {
11
+
12
+ exports.runRectTest = () => {
13
+
14
+ const main = async() => {
15
+ try {
16
+ console.log('_______________________________________________');
17
+ console.log('Opening the input pdf...');
18
+
19
+ const inputPath = '../TestFiles/';
20
+ const doc = await PDFNet.PDFDoc.createFromFilePath(inputPath + 'tiger.pdf');
21
+ doc.initSecurityHandler();
22
+
23
+ const pgItr1 = await doc.getPageIterator();
24
+ const mediaBox = await (await pgItr1.current()).getMediaBox();
25
+ mediaBox.x1 -= 200; // translate page 200 units left(1 uint = 1/72 inch)
26
+ mediaBox.x2 -= 200;
27
+
28
+ await mediaBox.update();
29
+
30
+ await doc.save(inputPath + 'Output/tiger_shift.pdf', 0);
31
+ console.log('Done. Result saved in tiger_shift...');
32
+ } catch (err) {
33
+ console.log(err);
34
+ }
35
+ };
36
+ PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error){console.log('Error: ' + JSON.stringify(error));}).then(function(){return PDFNet.shutdown();});
37
+ };
38
+ exports.runRectTest();
39
+ })(exports);
40
+ // eslint-disable-next-line spaced-comment
41
41
  //# sourceURL=AnnotationTest.js