asposepdfnodejs 24.2.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/Aspose.jpg +0 -0
- package/AsposePDFforNode.cjs +26 -0
- package/AsposePDFforNode.mjs +22 -0
- package/AsposePDFforNode.wasm +0 -0
- package/LICENSE.md +14 -0
- package/README.md +100 -0
- package/ReadMe.pdf +0 -0
- package/ReadMe.txt +11 -0
- package/example.cjs +273 -0
- package/example.mjs +269 -0
- package/license/3rdParty.pdf +0 -0
- package/license/eula.txt +8 -0
- package/package.json +96 -0
|
Binary file
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# EULA
|
|
2
|
+
|
|
3
|
+
The End User License Agreement ("EULA") contains the terms and conditions that
|
|
4
|
+
govern Your use of Aspose's products enclosed or otherwise accompanied herewith
|
|
5
|
+
(individually and collectively, the "PRODUCT") (as linked to below) and imposes
|
|
6
|
+
material limitations on Your License. You should read the EULA carefully. BY
|
|
7
|
+
INSTALLING, DOWNLOADING, COPYING OR OTHERWISE USING THE PRODUCT, YOU AGREE TO BE
|
|
8
|
+
BOUND BY THE TERMS OF THE ASPOSE EULA.
|
|
9
|
+
|
|
10
|
+
You may obtain a copy of the Aspose EULA at: https://about.aspose.com/legal/eula
|
|
11
|
+
|
|
12
|
+
## 3rd party Licenses
|
|
13
|
+
|
|
14
|
+
Please follow to ./license/3rdparty.pdf to get full info about 3rd party Licenses.
|
package/README.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Node.js API to Process & Manipulate PDF Files
|
|
2
|
+
|
|
3
|
+
Add PDF processing, manipulation, and conversion features to your Node.js applications.
|
|
4
|
+
|
|
5
|
+
[Aspose.PDF for Node.js via C++](https://products.aspose.com/pdf/nodejs-cpp/) allows you to work with PDF documents, pages, text, images, attachments, fonts, security, and signatures.
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a title="Download complete Aspose.PDF for Node.js via C++ code" href="https://releases.aspose.com/pdf/nodejscpp/new-releases/">
|
|
9
|
+
<img src="https://raw.github.com/AsposeExamples/java-examples-dashboard/master/images/downloadZip-Button-Large.png" />
|
|
10
|
+
</a>
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
## PDF Processing
|
|
14
|
+
|
|
15
|
+
- **Extract text** from PDF pages or search for a particular text segment using regular expressions.
|
|
16
|
+
- **Add or extract** images to & from PDF documents.
|
|
17
|
+
- **Concatenate** or **split** PDF files.
|
|
18
|
+
- **Linearization** of PDF documents for web optimization.
|
|
19
|
+
- **Convert** PDF documents to Office, web, and image formats with the highest visual fidelity.
|
|
20
|
+
- **Manipulate** PDF files to manage bookmarks, hyperlinks, watermarks, attachments & annotations.
|
|
21
|
+
- **Encrypt** or **decrypt** PDF documents and set document privileges or modify passwords.
|
|
22
|
+
- **Digitally sign PDF** documents or remove signatures. Also, verify if the PDF is signed and the signature is valid.
|
|
23
|
+
|
|
24
|
+
## Read & Write PDF & Other Formats
|
|
25
|
+
|
|
26
|
+
**Fixed Layout:** PDF, PDF/A
|
|
27
|
+
|
|
28
|
+
## Save PDF Documents As
|
|
29
|
+
|
|
30
|
+
- **Microsoft Office:** DOC, DOCX, XLS, XLSX, PPTX
|
|
31
|
+
- **Images:** JPEG, PNG, BMP, TIFF
|
|
32
|
+
- **Others:** EPUB, DICOM, SVG, SVG(ZIP), GRAYSCALE PDF, PDF/A, TEX, TXT
|
|
33
|
+
|
|
34
|
+
## Platform Independence
|
|
35
|
+
|
|
36
|
+
Aspose.PDF for Node.js via C++ is a WebAssembly-based library that can be used to create applications in Node.js environment.
|
|
37
|
+
The library was written in C++ and does not require additional runtime environments.
|
|
38
|
+
|
|
39
|
+
## Getting Started with Aspose.PDF for Node.js via C++
|
|
40
|
+
|
|
41
|
+
Are you ready to give Aspose.PDF for Node.js via C++ a try?
|
|
42
|
+
|
|
43
|
+
- Execute `npm install asposepdfnodejs` in Terminal in Visual Studio Code or in another console.
|
|
44
|
+
|
|
45
|
+
## Setting up
|
|
46
|
+
|
|
47
|
+
- You need arial.ttf and times.ttf fonts to perform basic operations
|
|
48
|
+
|
|
49
|
+
## Extract Text From Whole PDF
|
|
50
|
+
|
|
51
|
+
**CommonJS**:
|
|
52
|
+
```js
|
|
53
|
+
const AsposePdf = require('asposepdfnodejs');
|
|
54
|
+
const pdf_file = 'Aspose.pdf';
|
|
55
|
+
AsposePdf().then(AsposePdfModule => {
|
|
56
|
+
/*Extract text from a PDF-file*/
|
|
57
|
+
const json = AsposePdfModule.AsposePdfExtractText(pdf_file);
|
|
58
|
+
console.log("AsposePdfExtractText => %O", json.errorCode == 0 ? json.extractText : json.errorText);
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
**ECMAScript/ES6**:
|
|
62
|
+
```js
|
|
63
|
+
import AsposePdf from 'asposepdfnodejs';
|
|
64
|
+
const AsposePdfModule = await AsposePdf();
|
|
65
|
+
const pdf_file = 'Aspose.pdf';
|
|
66
|
+
/*Extract text from a PDF-file*/
|
|
67
|
+
const json = AsposePdfModule.AsposePdfExtractText(pdf_file);
|
|
68
|
+
console.log("AsposePdfExtractText => %O", json.errorCode == 0 ? json.extractText : json.errorText);
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Save PDF as Office Formats
|
|
72
|
+
|
|
73
|
+
One of the most popular features of Aspose.PDF for Node.js via C++ is to convert PDF documents to other formats without needing to understand the underlying structure of the resultant format.
|
|
74
|
+
|
|
75
|
+
Give the following snippet a try with your samples:
|
|
76
|
+
|
|
77
|
+
**CommonJS**:
|
|
78
|
+
|
|
79
|
+
```js
|
|
80
|
+
const AsposePdf = require('asposepdfnodejs');
|
|
81
|
+
const pdf_file = 'Aspose.pdf';
|
|
82
|
+
AsposePdf().then(AsposePdfModule => {
|
|
83
|
+
/*Convert a PDF-file to DocX and save the "ResultPDFtoDocX.docx"*/
|
|
84
|
+
const json = AsposePdfModule.AsposePdfToDocX(pdf_file, "ResultPDFtoDocX.docx");
|
|
85
|
+
console.log("AsposePdfToDocX => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**ECMAScript/ES6**:
|
|
90
|
+
|
|
91
|
+
```js
|
|
92
|
+
import AsposePdf from 'asposepdfnodejs';
|
|
93
|
+
const AsposePdfModule = await AsposePdf();
|
|
94
|
+
const pdf_file = 'Aspose.pdf';
|
|
95
|
+
/*Convert a PDF-file to DocX and save the "ResultPDFtoDocX.docx"*/
|
|
96
|
+
const json = AsposePdfModule.AsposePdfToDocX(pdf_file, "ResultPDFtoDocX.docx");
|
|
97
|
+
console.log("AsposePdfToDocX => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
[Home](https://www.aspose.com/) | [Product Page](https://products.aspose.com/pdf/nodejs-cpp/) | [Docs](https://docs.aspose.com/pdf/nodejs-cpp/) | [Demos](https://products.aspose.app/pdf/family) | [API Reference](https://reference.aspose.com/pdf/nodejs-cpp/) | [Examples](https://github.com/aspose-pdf/aspose-pdf-js) | [Blog](https://blog.aspose.com/category/pdf/) | [Search](https://search.aspose.com/) | [Free Support](https://forum.aspose.com/c/pdf) | [Temporary License](https://purchase.aspose.com/temporary-license)
|
package/ReadMe.pdf
ADDED
|
Binary file
|
package/ReadMe.txt
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
This is Aspose.PDF for Node.js via C++ release.
|
|
2
|
+
In this release we provide support of PDF for Node.js.
|
|
3
|
+
The "snippets" folder contains code snippets for each function.
|
|
4
|
+
You need arial.ttf and times.ttf fonts to run example successfuly.
|
|
5
|
+
To run the CommonJS example:
|
|
6
|
+
node example.cjs
|
|
7
|
+
To run the ECMAScript (ES6) example:
|
|
8
|
+
node example.mjs
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
package/example.cjs
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
const AsposePdf = require('./AsposePDFforNode.cjs');
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const os = require("os");
|
|
4
|
+
|
|
5
|
+
const pdf_file = './ReadMe.pdf';
|
|
6
|
+
const aspose_file = './Aspose.jpg';
|
|
7
|
+
const resultdir = !!process.platform.match(/^win/) ? '' : fs.realpathSync(os.tmpdir()) + '/';
|
|
8
|
+
|
|
9
|
+
console.log('Aspose.PDF for Node.js via C++ example');
|
|
10
|
+
|
|
11
|
+
AsposePdf().then(AsposePdfModule => {
|
|
12
|
+
|
|
13
|
+
console.log('Result dir: %O', resultdir);
|
|
14
|
+
|
|
15
|
+
var json;
|
|
16
|
+
|
|
17
|
+
/*About*/
|
|
18
|
+
console.log("Miscellaneous:");
|
|
19
|
+
|
|
20
|
+
//AsposePdfAbout - Get info about Product
|
|
21
|
+
json = AsposePdfModule.AsposePdfAbout();
|
|
22
|
+
console.log("01. AsposePdfAbout => %O", json.errorCode == 0 ? JSON.parse(JSON.stringify(json).replace('"errorCode":0,"errorText":"",','')) : json.errorText);
|
|
23
|
+
|
|
24
|
+
/*Convert from PDF*/
|
|
25
|
+
console.log("Convert from PDF:");
|
|
26
|
+
|
|
27
|
+
//AsposePdfPagesToJpg - Convert a PDF-file to JPG
|
|
28
|
+
json = AsposePdfModule.AsposePdfPagesToJpg(pdf_file, resultdir + "ResultPdfToJpg{0:D2}.jpg", 150);
|
|
29
|
+
console.log("01. AsposePdfPagesToJpg => %O", json.errorCode == 0 ? json.filesNameResult : json.errorText);
|
|
30
|
+
|
|
31
|
+
//AsposePdfPagesToPng - Convert a PDF-file to PNG
|
|
32
|
+
json = AsposePdfModule.AsposePdfPagesToPng(pdf_file, resultdir + "ResultPdfToPng{0:D2}.png", 150);
|
|
33
|
+
console.log("02. AsposePdfPagesToPng => %O", json.errorCode == 0 ? json.filesNameResult : json.errorText);
|
|
34
|
+
|
|
35
|
+
//AsposePdfPagesToTiff - Convert a PDF-file to TIFF
|
|
36
|
+
json = AsposePdfModule.AsposePdfPagesToTiff(pdf_file, resultdir + "ResultPdfToTiff{0:D2}.tiff", 300);
|
|
37
|
+
console.log("03. AsposePdfPagesToTiff => %O", json.errorCode == 0 ? json.filesNameResult : json.errorText);
|
|
38
|
+
|
|
39
|
+
//AsposePdfPagesToBmp - Convert a PDF-file to BMP
|
|
40
|
+
json = AsposePdfModule.AsposePdfPagesToBmp(pdf_file, resultdir + "ResultPdfToBmp{0:D2}.bmp", 150);
|
|
41
|
+
console.log("04. AsposePdfPagesToBmp => %O", json.errorCode == 0 ? json.filesNameResult : json.errorText);
|
|
42
|
+
|
|
43
|
+
//AsposePdfPagesToDICOM - Convert a PDF-file to DICOM
|
|
44
|
+
json = AsposePdfModule.AsposePdfPagesToDICOM(pdf_file, resultdir + "ResultPdfToDICOM{0:D2}.dcm", 150);
|
|
45
|
+
console.log("05. AsposePdfPagesToDICOM => %O", json.errorCode == 0 ? json.filesNameResult : json.errorText);
|
|
46
|
+
|
|
47
|
+
//AsposePdfPagesToSvg - Convert a PDF-file to SVG
|
|
48
|
+
json = AsposePdfModule.AsposePdfPagesToSvg(pdf_file, resultdir + "ResultPdfToSvg.svg");
|
|
49
|
+
console.log("06. AsposePdfPagesToSvg => %O", json.errorCode == 0 ? json.filesNameResult : json.errorText);
|
|
50
|
+
|
|
51
|
+
//AsposePdfPagesToSvgZip - Convert a PDF-file to SVG(zip)
|
|
52
|
+
json = AsposePdfModule.AsposePdfPagesToSvgZip(pdf_file, resultdir + "ResultPdfToSvgZip.zip");
|
|
53
|
+
console.log("07. AsposePdfPagesToSvgZip => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
54
|
+
|
|
55
|
+
//AsposePdfToTeX - Convert a PDF-file to TeX
|
|
56
|
+
json = AsposePdfModule.AsposePdfToTeX(pdf_file, resultdir + "ResultPdfToTeX.tex");
|
|
57
|
+
console.log("08. AsposePdfToTeX => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
58
|
+
|
|
59
|
+
//AsposePdfToXps - Convert a PDF-file to Xps
|
|
60
|
+
json = AsposePdfModule.AsposePdfToXps(pdf_file, resultdir + "ResultPdfToXps.xps");
|
|
61
|
+
console.log("09. AsposePdfToXps => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
62
|
+
|
|
63
|
+
//AsposePdfTablesToCSV - Convert a PDF-file to CSV (extract tables)
|
|
64
|
+
json = AsposePdfModule.AsposePdfTablesToCSV(pdf_file, resultdir + "ResultPdfTablesToCSV{0:D2}.csv", "\t");
|
|
65
|
+
console.log("10. AsposePdfTablesToCSV => %O", json.errorCode == 0 ? json.filesNameResult : json.errorText);
|
|
66
|
+
|
|
67
|
+
//AsposePdfToTxt - Convert a PDF-file to Txt
|
|
68
|
+
json = AsposePdfModule.AsposePdfToTxt(pdf_file, resultdir + "ResultPdfToTxt.txt");
|
|
69
|
+
console.log("11. AsposePdfToTxt => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
70
|
+
|
|
71
|
+
//AsposePdfConvertToGrayscale - Convert a PDF-file to grayscale
|
|
72
|
+
json = AsposePdfModule.AsposePdfConvertToGrayscale(pdf_file, resultdir + "ResultConvertToGrayscale.pdf");
|
|
73
|
+
console.log("12. AsposePdfConvertToGrayscale => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
74
|
+
|
|
75
|
+
//AsposePdfConvertToPDFA - Convert a PDF-file to PDF/A
|
|
76
|
+
json = AsposePdfModule.AsposePdfConvertToPDFA(pdf_file,AsposePdfModule.PdfFormat.PDF_A_1A, resultdir + "ResultConvertToPDFA.pdf", resultdir + "ResultConvertToPDFALog.xml");
|
|
77
|
+
console.log("13. AsposePdfConvertToPDFA => %O", json.errorCode == 0 ? [json.fileNameResult, json.fileNameLogResult] : json.errorText);
|
|
78
|
+
|
|
79
|
+
//AsposePdfAConvertToPDF - Convert a PDF/A-file to PDF
|
|
80
|
+
json = AsposePdfModule.AsposePdfAConvertToPDF(resultdir + "ResultConvertToPDFA.pdf", resultdir + "ResultConvertToPDF.pdf");
|
|
81
|
+
console.log("14. AsposePdfAConvertToPDF => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
82
|
+
|
|
83
|
+
//AsposePdfToDocX - Convert a PDF-file to DocX
|
|
84
|
+
json = AsposePdfModule.AsposePdfToDocX(pdf_file, resultdir + "ResultPdfToDocX.docx");
|
|
85
|
+
console.log("15. AsposePdfToDocX => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
86
|
+
|
|
87
|
+
//AsposePdfToXlsX - Convert a PDF-file to XlsX
|
|
88
|
+
json = AsposePdfModule.AsposePdfToXlsX(pdf_file, resultdir + "ResultPdfToXlsX.xlsx");
|
|
89
|
+
console.log("16. AsposePdfToXlsX => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
90
|
+
|
|
91
|
+
//AsposePdfToEPUB - Convert a PDF-file to ePub
|
|
92
|
+
json = AsposePdfModule.AsposePdfToEPUB(pdf_file, resultdir + "ResultPdfToEPUB.epub");
|
|
93
|
+
console.log("17. AsposePdfToEPUB => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
94
|
+
|
|
95
|
+
//AsposePdfToDoc - Convert a PDF-file to Doc
|
|
96
|
+
json = AsposePdfModule.AsposePdfToDoc(pdf_file, resultdir + "ResultPdfToDoc.doc");
|
|
97
|
+
console.log("18. AsposePdfToDoc => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
98
|
+
|
|
99
|
+
//AsposePdfToPptX - Convert a PDF-file to PptX
|
|
100
|
+
json = AsposePdfModule.AsposePdfToPptX(pdf_file, resultdir + "ResultPdfToPptX.pptx");
|
|
101
|
+
console.log("19. AsposePdfToPptX => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
102
|
+
|
|
103
|
+
//AsposePdfExtractText - Extract text from a PDF-file
|
|
104
|
+
json = AsposePdfModule.AsposePdfExtractText(pdf_file);
|
|
105
|
+
console.log("20. AsposePdfExtractText => %O", json.errorCode == 0 ? json.extractText.split('\n')[1] : json.errorText);
|
|
106
|
+
|
|
107
|
+
//AsposePdfExtractImage - Extract image from a PDF-file
|
|
108
|
+
json = AsposePdfModule.AsposePdfExtractImage(pdf_file, resultdir + "ResultPdfExtractImage{0:D2}.jpg", 150);
|
|
109
|
+
console.log("21. AsposePdfExtractImage => %O", json.errorCode == 0 ? json.filesNameResult : json.errorText);
|
|
110
|
+
|
|
111
|
+
//AsposePdfExportFdf - Export from a PDF-file with AcroForm to FDF
|
|
112
|
+
json = AsposePdfModule.AsposePdfExportFdf(pdf_file, resultdir + "ResultPdfExportFdf.fdf");
|
|
113
|
+
console.log("22. AsposePdfExportFdf => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
114
|
+
|
|
115
|
+
//AsposePdfExportXfdf - Export from a PDF-file with AcroForm to XFDF
|
|
116
|
+
json = AsposePdfModule.AsposePdfExportXfdf(pdf_file, resultdir + "ResultPdfExportXfdf.xfdf");
|
|
117
|
+
console.log("23. AsposePdfExportXfdf => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
118
|
+
|
|
119
|
+
//AsposePdfExportXml - Export from a PDF-file with AcroForm to XML
|
|
120
|
+
json = AsposePdfModule.AsposePdfExportXml(pdf_file, resultdir + "ResultPdfExportXml.xml");
|
|
121
|
+
console.log("24. AsposePdfExportXml => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
122
|
+
|
|
123
|
+
/*Convert to PDF*/
|
|
124
|
+
console.log("Convert to PDF:");
|
|
125
|
+
|
|
126
|
+
//AsposePdfFromTxt - Convert a TXT-file to PDF
|
|
127
|
+
json = AsposePdfModule.AsposePdfFromTxt('./ReadMe.txt', resultdir + "ResultPdfFromTxt.pdf");
|
|
128
|
+
console.log("01. AsposePdfFromTxt => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
129
|
+
|
|
130
|
+
/*Organize PDF*/
|
|
131
|
+
console.log("Organize PDF:");
|
|
132
|
+
|
|
133
|
+
//AsposePdfOptimize - Optimize a PDF-file
|
|
134
|
+
json = AsposePdfModule.AsposePdfOptimize(pdf_file, resultdir + "ResultOptimize.pdf");
|
|
135
|
+
console.log("01. AsposePdfOptimize => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
136
|
+
|
|
137
|
+
//AsposePdfMerge2Files - Merge two PDF-files
|
|
138
|
+
json = AsposePdfModule.AsposePdfMerge2Files(pdf_file, pdf_file, resultdir + "ResultMerge.pdf");
|
|
139
|
+
console.log("02. AsposePdfMerge2Files => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
140
|
+
|
|
141
|
+
//AsposePdfSplit2Files - Split to two PDF-files
|
|
142
|
+
json = AsposePdfModule.AsposePdfSplit2Files(resultdir + "ResultMerge.pdf", 1, resultdir + "ResultSplit1.pdf", resultdir + "ResultSplit2.pdf");
|
|
143
|
+
console.log("03. AsposePdfSplit2Files => %O", json.errorCode == 0 ? [json.fileNameResult1, json.fileNameResult2] : json.errorText);
|
|
144
|
+
|
|
145
|
+
//AsposePdfRotateAllPages - Rotate PDF-pages
|
|
146
|
+
json = AsposePdfModule.AsposePdfRotateAllPages(pdf_file, AsposePdfModule.Rotation.on270, resultdir + "ResultRotation.pdf");
|
|
147
|
+
console.log("04. AsposePdfRotateAllPages => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
148
|
+
|
|
149
|
+
//AsposePdfDeletePages - Delete pages from a PDF-file
|
|
150
|
+
json = AsposePdfModule.AsposePdfDeletePages(resultdir + "ResultMerge.pdf", resultdir + "ResultDeletePages.pdf", 1);
|
|
151
|
+
console.log("05. AsposePdfDeletePages => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
152
|
+
|
|
153
|
+
//AsposePdfAddStamp - Add stamp to a PDF-file
|
|
154
|
+
json = AsposePdfModule.AsposePdfAddStamp(pdf_file, aspose_file, 0, 5, 5, 40, 40, AsposePdfModule.Rotation.on270, 0.5, resultdir + "ResultAddStamp.pdf");
|
|
155
|
+
console.log("06. AsposePdfAddStamp => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
156
|
+
|
|
157
|
+
//AsposePdfAddImage - Add an image to end a PDF-file
|
|
158
|
+
json = AsposePdfModule.AsposePdfAddImage(pdf_file, aspose_file, resultdir + "ResultAddImage.pdf");
|
|
159
|
+
console.log("07. AsposePdfAddImage => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
160
|
+
|
|
161
|
+
//AsposePdfAddPageNum - Add page number to a PDF-file
|
|
162
|
+
json = AsposePdfModule.AsposePdfAddPageNum(pdf_file, resultdir + "ResultAddPageNum.pdf");
|
|
163
|
+
console.log("08. AsposePdfAddPageNum => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
164
|
+
|
|
165
|
+
//AsposePdfAddBackgroundImage - Add background image to a PDF-file
|
|
166
|
+
json = AsposePdfModule.AsposePdfAddBackgroundImage(pdf_file, aspose_file, resultdir + "ResultAddBackgroundImage.pdf");
|
|
167
|
+
console.log("09. AsposePdfAddBackgroundImage => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
168
|
+
|
|
169
|
+
//AsposePdfAddTextHeaderFooter - Add text in Header/Footer of a PDF-file
|
|
170
|
+
json = AsposePdfModule.AsposePdfAddTextHeaderFooter(pdf_file, "Aspose.PDF for Node.js via C++", "ASPOSE", resultdir + "ResultAddHeaderFooter.pdf");
|
|
171
|
+
console.log("10. AsposePdfAddTextHeaderFooter => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
172
|
+
|
|
173
|
+
//AsposePdfRepair - Repair a PDF-file
|
|
174
|
+
json = AsposePdfModule.AsposePdfRepair(pdf_file, resultdir + "ResultPdfRepair.pdf");
|
|
175
|
+
console.log("11. AsposePdfRepair => %O", json.errorCode == 0 ? JSON.parse(JSON.stringify(json).replace('"errorCode":0,"errorText":"",','')) : json.errorText);
|
|
176
|
+
|
|
177
|
+
//AsposePdfOptimizeResource - Optimize resources of PDF-file
|
|
178
|
+
json = AsposePdfModule.AsposePdfOptimizeResource(pdf_file, resultdir + "ResultPdfOptimizeResource.pdf");
|
|
179
|
+
console.log("12. AsposePdfOptimizeResource => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
180
|
+
|
|
181
|
+
//AsposePdfSetBackgroundColor - Set the background color for the PDF-file
|
|
182
|
+
json = AsposePdfModule.AsposePdfSetBackgroundColor(pdf_file, "#426bf4", resultdir + "ResultPdfSetBackgroundColor.pdf");
|
|
183
|
+
console.log("13. AsposePdfSetBackgroundColor => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
184
|
+
|
|
185
|
+
//AsposePdfDeleteAnnotations - Delete annotations from a PDF-file
|
|
186
|
+
json = AsposePdfModule.AsposePdfDeleteAnnotations(pdf_file, resultdir + "ResultPdfDeleteAnnotations.pdf");
|
|
187
|
+
console.log("14. AsposePdfDeleteAnnotations => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
188
|
+
|
|
189
|
+
//AsposePdfDeleteBookmarks - Delete bookmarks from a PDF-file
|
|
190
|
+
json = AsposePdfModule.AsposePdfDeleteBookmarks(pdf_file, resultdir + "ResultPdfDeleteBookmarks.pdf");
|
|
191
|
+
console.log("15. AsposePdfDeleteBookmarks => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
192
|
+
|
|
193
|
+
//AsposePdfDeleteAttachments - Delete attachments from a PDF-file
|
|
194
|
+
json = AsposePdfModule.AsposePdfDeleteAttachments(pdf_file, resultdir + "ResultPdfDeleteAttachments.pdf");
|
|
195
|
+
console.log("16. AsposePdfDeleteAttachments => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
196
|
+
|
|
197
|
+
//AsposePdfDeleteImages - Delete images from a PDF-file
|
|
198
|
+
json = AsposePdfModule.AsposePdfDeleteImages(pdf_file, resultdir + "ResultPdfDeleteImages.pdf");
|
|
199
|
+
console.log("17. AsposePdfDeleteImages => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
200
|
+
|
|
201
|
+
//AsposePdfDeleteJavaScripts - Delete JavaScripts from a PDF-file
|
|
202
|
+
json = AsposePdfModule.AsposePdfDeleteJavaScripts(pdf_file, resultdir + "ResultPdfDeleteJavaScripts.pdf");
|
|
203
|
+
console.log("18. AsposePdfDeleteJavaScripts => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
204
|
+
|
|
205
|
+
//AsposePdfAddAttachment - Add attachment to a PDF-file
|
|
206
|
+
json = AsposePdfModule.AsposePdfAddAttachment(pdf_file, './ReadMe.txt', "Description", resultdir + "ResultPdfAddAttachment.pdf");
|
|
207
|
+
console.log("19. AsposePdfAddAttachment => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
208
|
+
|
|
209
|
+
//AsposePdfGetAttachment - Get attachment from a PDF-file
|
|
210
|
+
json = AsposePdfModule.AsposePdfGetAttachment(resultdir + "ResultPdfAddAttachment.pdf", resultdir + "ResultPdfGetAttachment_{0}");
|
|
211
|
+
console.log("20. AsposePdfGetAttachment => %O", json.errorCode == 0 ? json.filesNameResult : json.errorText);
|
|
212
|
+
|
|
213
|
+
//AsposePdfReplaceText - Replace text in a PDF-file
|
|
214
|
+
json = AsposePdfModule.AsposePdfReplaceText(pdf_file, "Aspose", "ASPOSE", resultdir + "ResultPdfReplaceText.pdf");
|
|
215
|
+
console.log("21. AsposePdfReplaceText => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
216
|
+
|
|
217
|
+
//AsposePdfFindText - Find text in a PDF-file
|
|
218
|
+
json = AsposePdfModule.AsposePdfFindText(pdf_file, "Aspose");
|
|
219
|
+
console.log("22. AsposePdfFindText => %O", json.errorCode == 0 ? JSON.parse(JSON.stringify(json).replace('"errorCode":0,"errorText":"",','')) : json.errorText);
|
|
220
|
+
|
|
221
|
+
/*Metadata PDF*/
|
|
222
|
+
console.log("Metadata PDF:");
|
|
223
|
+
|
|
224
|
+
//AsposePdfSetInfo - Set info (metadata) in a PDF-file
|
|
225
|
+
json = AsposePdfModule.AsposePdfSetInfo(pdf_file, "Setting PDF Document Information", "", "Aspose", undefined, "Aspose.Pdf, DOM, API", undefined, "05/05/2023 11:55 PM", resultdir + "ResultSetInfo.pdf");
|
|
226
|
+
console.log("01. AsposePdfSetInfo => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
227
|
+
|
|
228
|
+
//AsposePdfGetInfo - Get info (metadata) from a PDF-file
|
|
229
|
+
json = AsposePdfModule.AsposePdfGetInfo(resultdir + "ResultSetInfo.pdf");
|
|
230
|
+
console.log("02. AsposePdfGetInfo => %O", json.errorCode == 0 ? JSON.parse(JSON.stringify(json).replace('"errorCode":0,"errorText":"",','')) : json.errorText);
|
|
231
|
+
|
|
232
|
+
//AsposePdfGetAllFonts - Get list fonts from a PDF-file
|
|
233
|
+
json = AsposePdfModule.AsposePdfGetAllFonts(pdf_file);
|
|
234
|
+
console.log("03. AsposePdfGetAllFonts => fonts: %O", json.errorCode == 0 ? json.fonts : json.errorText);
|
|
235
|
+
|
|
236
|
+
//AsposePdfRemoveMetadata - Remove metadata from a PDF-file
|
|
237
|
+
json = AsposePdfModule.AsposePdfRemoveMetadata(pdf_file, resultdir + "ResultPdfRemoveMetadata.pdf");
|
|
238
|
+
console.log("04. AsposePdfRemoveMetadata => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
239
|
+
|
|
240
|
+
/*Security PDF*/
|
|
241
|
+
console.log("Security PDF:");
|
|
242
|
+
|
|
243
|
+
//AsposePdfEncrypt - Encrypt a PDF-file
|
|
244
|
+
json = AsposePdfModule.AsposePdfEncrypt(pdf_file, "user", "owner", AsposePdfModule.Permissions.PrintDocument, AsposePdfModule.CryptoAlgorithm.RC4x40, resultdir + "ResultEncrypt.pdf");
|
|
245
|
+
console.log("01. AsposePdfEncrypt => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
246
|
+
|
|
247
|
+
//AsposePdfDecrypt - Decrypt a PDF-file
|
|
248
|
+
json = AsposePdfModule.AsposePdfDecrypt(resultdir + "ResultEncrypt.pdf", "owner", resultdir + "ResultDecrypt.pdf");
|
|
249
|
+
console.log("02. AsposePdfDecrypt => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
250
|
+
|
|
251
|
+
//AsposePdfSignPKCS7 - Sign a PDF-file with digital signatures
|
|
252
|
+
//Key PKCS7 for test, converted to Base64, with "Pa$$w0rd2023" password
|
|
253
|
+
const test_pfx_file = resultdir +'sign.pfx';
|
|
254
|
+
const test_pfx_data = "MIIEcQIBAzCCBDcGCSqGSIb3DQEHAaCCBCgEggQkMIIEIDCCAj8GCSqGSIb3DQEHBqCCAjAwggIsAgEAMIICJQYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQYwDgQI4tjRHb+OMLsCAggAgIIB+OAPdXDmh+6qTyjHkumo2euCw4EvRZ8qSha/AAWYespZs8mA9dInLWM33HeDqktHEcZoPf/CCWqQopRA6RPFAYIn9ioR8s3Phd3LmoMPb52SKJMvWjRGRppLyo4gCNZfv37duV8+mKTSyDW1wrtHsZnvLlUHmy8+OcG8zsAAX6YwHTMkafllpRKkB0kmO1boSvHEp5IPsU8u50VpF21OXYNV7D5c4W2O1GrV0a5HD6OyObHJjj+ufPF7nh+qEuPN/b8hm14y+sZPoVSRvwtH+O8VVDxnJWX+y+jGhChLxiYUYRnhBMW6X+cZW9bcpXZIkFdQdPWA1/opOdTguHlXQF1R+JNnUUOtopwX103undyPGl5JGXvLrr6iH2aO1GY1p2Asd1exaQdfwFQynCxlZrKaCc2JBs5Jem5/wWN6rfq+n15tsYvk2gTP+U/icla8wp1NsqqTGOe0dAJNH3kDOwxKVb5gU+fOYbFWI/6iZ3Tdl41W66rE4Gxj937oYJE1KUK3SlxJtL0uK5c3ZN9yMJYdpc9k2HQ1VOssuUKrmpuOcyJhpF4XosHxMyQxPFFVA/TNggb3Dv3cr2Qei+JqF4n4KAqYCY5u0O+y6+R9Ig0L5zCL/n9cWyPyYqqvEH4ICxqUoH05qCJIMdiNlc5w1PYUXKaSRSzK0TCCAdkGCSqGSIb3DQEHAaCCAcoEggHGMIIBwjCCAb4GCyqGSIb3DQEMCgECoIIBhjCCAYIwHAYKKoZIhvcNAQwBAzAOBAgWFTAixF9bPAICCAAEggFgwC4A+R9X2xdbdfz0IKw2f7pe3iJdgLKJPYiUDV2cGfQnM4UuQKu9qIZ3lAzBtQcF09Wy6pwwU63nVHiGZ6y9PunZZ3tIM24I0Ii1Q5PrphvT4z7yXPqI+sv53AhzwpTJ2XHJQRf53PX7V8ujv3k8lfBQ6gYxfFMkrTdZlfiWeoWZSlFMKUzmaRfBFVit5BRUNEgZrySfZxyxULpo+KzQ/b5K0Z69x6Gvj/j21gEkGTEDWhmjECjsPCP+sWDMyB1xOxHimJgmLtSHc7hpdE/xuRBVELxhlFI1lYj3fbWbnMNzeLG+OBaoktbpr9kbsWRM568vLxdV7XZYkaoGEd+SEUTR+Yxyak/DHspkO/o4apjOh24U6GCqfqPl4ucxTMvOiYpobrxPub/sqQPXB0NEsqNPjcYdsT1y1YkYMxO0b1heh8TWat6SYk1dLi1wdV0iGf8LTImqzzUobZNBfrybjzElMCMGCSqGSIb3DQEJFTEWBBRBGCVJ5N72ukaNrJUetg4Rp0/41DAxMCEwCQYFKw4DAhoFAAQU8VT/8VxDX7Sx3p05TO3BNne5YXYECJhmeDAQpwBNAgIIAA==";
|
|
255
|
+
fs.writeFileSync(test_pfx_file, test_pfx_data, {encoding: 'base64'});
|
|
256
|
+
//Sign: signatureAppearance
|
|
257
|
+
const sign_png_file = resultdir +'sign.png';
|
|
258
|
+
const sign_png_data = "iVBORw0KGgoAAAANSUhEUgAAAGQAAAAyCAIAAAAlV+npAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAT6SURBVGhD7ZptTFtVGIBbyqUrbddALRA/gtuYEzs2J5sRBQPZcEUgAwvBDQxOUZP5ScwSl/jDfzPxx4wfi3M4rYNVAkwWZygy4w/RkoyxzVkZg4nMNBaQkVKgdP3At56TI8y2XPWe23MTnx/AfeHXk/c8vTcX+eLioux/+JGAv0uTQDDQ7xzAF/SRtqz9Pa8XWcp6x+z4mjISPoadg6crW2vhB02Suqu2Iz8zD83pIdXN+mV6bO+pfSpd6KFSbVDlKWkxi7BfkpQFqapuq/cpp4vrklO2ObfvSUa+bMM9+C/oIElZkCrH3Ln7diSFDBPh6/QJ5KvcWtPu6PzzT6ggPVmQqiOD76/dGkzJuY5HQPqEqUHJaf27O56i50tigYdUbTlSsNo4ual8AY+WwHn0tiaf38NZzceqjBV4KhxS2iySqnsfWI1Hy/Frpx597NZAKAj7NTJ1FU+FQ0qyXuzavyxVkXBNzMHXuk01Wfp1aCIgkpH12aV2y3DTzalajuJ62kCve2Na9rslb+GRoEhDFpypZ754yZAVWFPgxaNInP9uRuHVQrA0Sg0eCYoEZC34FyBVcGcQLVWIa3b15Egi7NTG9HvwSGgkIKux+8CQ92LsVM0M6of75DVr6p7cEn4AogTrsnim6qzNt05ppJQqAtOy/lGq2qo/pZQqAruyZn2zla21PFN1tPyduw134RE12JUFd1VXfQ4+qapf3/B4ThUe0YRRWZ+cb2kdbeaTqg2qzYd2HsQjyrAo68fxn2CteKfKsopbhUeUYU4WpAqe7PinisZjTTSoy4I1gbtKfMEDPqmavpQqZqoIdGW1Ozq3HS0sPr4L9gWPYsInVQmTaQNnboiZKgJFWWAKDtRCwNd7ra+kxbyiL56putAndqoItGQhU5zWb96bsbmQO+f+PrYvnndVo9+qxE8VgYosYsrUoPRlXrmjcMr4cEJsX3Cn7gyOrJiqn/sV4qeKILyspab82ik0zMidARHIl8szjoaED85+dOrXNmZTRRBYVkRTCBCx9ZGwryJL6VJfF377obH7AMupIggpq/liazRTCJ0x7GvMP0R8wamsbquXq718UnW88sO4pIogmCxYkCc+fzYQChYUGyKaQtzki3+qnst+viK7DI/ihJCvwt62H4YDpdKFdr6wGODCLw6i4Xak9n91Q+2/ZY77HVIV4wBCqnqa543qXPvTZxIViXgaJ4Q8hq/k7YP6et0J3e/JuQUdnkYC7ReY4pMqpS8FUhV3U4DwL1nJfkUrF8E7bNDo5cHUqAcQUgUH8ITJGvcDiKDyRjrGZyJ/IFVwrwCpOmR6E4/iDa3X9//RF1OpIgh/U4qoMlZYzcf8Hs7W5OM8ejzlDVOpItCSBfxrX+iu6uNdh+9MycQjNqAoC1jqC04WnsaEnbuqvyPGvxydHrJBv4Iqz/Y9ybL0qJ99AJupItDdLETZBlNXbQc82X19Yl42Hmu/2EwVQQxZQH5m3oq+yAMga6kiiCQLiO0LperlnFdhDfGIPcRo1lJ6x+wlLeZwv3YnyzJwv1CqcnUPflP/JZsHECHeZiH+2i/rvG/UgIaQKniohs9Nlk0BYm8W4vLklSJLqVvhur8wxemadl6WnSw7aVpfjH/NKvGRBSBfrtnwSXwtv/HgjjfQnGXiJgtAvrJS1zKeKkI8ZQHgS5Okvl13G75mmzjLkhIy2R/qB+VUhKQ5zAAAAABJRU5ErkJggg==";
|
|
259
|
+
fs.writeFileSync(sign_png_file, sign_png_data, {encoding: 'base64'});
|
|
260
|
+
//AsposePdfSignPKCS7
|
|
261
|
+
json = AsposePdfModule.AsposePdfSignPKCS7(pdf_file, 1, test_pfx_file, "Pa$$w0rd2023", 100, 100, 200, 100, "Reason", "Contact", "Location", 1, sign_png_file, resultdir + "ResultSignPKCS7.pdf");
|
|
262
|
+
console.log("03. AsposePdfSignPKCS7 => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
263
|
+
//delete tmp files
|
|
264
|
+
fs.unlinkSync(test_pfx_file);
|
|
265
|
+
fs.unlinkSync(sign_png_file);
|
|
266
|
+
|
|
267
|
+
//AsposePdfChangePassword - Change passwords of the PDF-file
|
|
268
|
+
json = AsposePdfModule.AsposePdfChangePassword(resultdir + "ResultEncrypt.pdf", "owner", "newuser", "newowner", resultdir + "ResultChangePassword.pdf");
|
|
269
|
+
console.log("04. AsposePdfChangePassword => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
|
|
270
|
+
|
|
271
|
+
},
|
|
272
|
+
reason => {console.log(`The unknown error has occurred: ${reason}`);}
|
|
273
|
+
);
|