|
| 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, including search via regular expressions and hidden text detection. |
| 16 | +- **Add or extract images** to and from PDF documents; remove or replace images when needed. |
| 17 | +- **Concatenate**, **split**, or **reorganize** PDF files; delete specific or blank pages. |
| 18 | +- **Linearize** PDF documents for web optimization and **optimize** internal structure and resources. |
| 19 | +- **Convert** PDF documents to: |
| 20 | + - **Office formats:** DOC, DOCX, XLS, XLSX, PPTX |
| 21 | + - **Web formats:** SVG, SVG (ZIP), XPS, EPUB |
| 22 | + - **Image formats:** JPEG, PNG, BMP, TIFF, DICOM |
| 23 | + - **Other formats:** Grayscale PDF, PDF/A, TeX, TXT |
| 24 | +- **Manipulate** PDF structure and content: |
| 25 | + - Bookmarks, hyperlinks, annotations, attachments, JavaScript |
| 26 | + - Fonts, metadata, layers, background color |
| 27 | +- **Secure PDF documents**: |
| 28 | + - Encrypt, decrypt, set or change passwords |
| 29 | + - Configure access permissions |
| 30 | +- **Digitally sign** PDFs using PKCS#7, validate and remove signatures. |
| 31 | +- **Add or remove** watermarks, stamps, page numbers, headers/footers, background images. |
| 32 | +- **Flatten** PDF documents (forms, annotations, layers). |
| 33 | +- **Create booklets** or generate **N-Up layouts**. |
| 34 | +- **Export form data** (AcroForm) to FDF, XFDF, XML. |
| 35 | +- **Validate** and **convert** to/from **PDF/A** format. |
| 36 | + |
| 37 | +## Read & Write PDF & Other Formats |
| 38 | + |
| 39 | +**Fixed Layout Support:** |
| 40 | +- PDF, PDF/A |
| 41 | + |
| 42 | +**Save/Export As:** |
| 43 | +- **Office:** DOC, DOCX, XLS, XLSX, PPTX |
| 44 | +- **Images:** JPEG, PNG, BMP, TIFF, DICOM |
| 45 | +- **Other:** EPUB, SVG, SVG (ZIP), TeX, TXT, Grayscale PDF, PDF/A, XPS |
| 46 | + |
| 47 | +**Input Formats:** |
| 48 | +- TXT, Images (JPEG/PNG/BMP/TIFF) |
| 49 | + |
| 50 | +## Advanced Features |
| 51 | + |
| 52 | +- **Fonts:** List, embed/unembed, and replace fonts in PDF files. |
| 53 | +- **Metadata:** Set, extract, or remove metadata. |
| 54 | +- **Layers:** Get list of layers, merge or flatten them. |
| 55 | +- **Forms & Annotations:** |
| 56 | + - Delete annotations, bookmarks, JavaScript |
| 57 | + - Flatten forms |
| 58 | +- **Attachments:** Add, extract, or delete file attachments. |
| 59 | +- **Text Tools:** |
| 60 | + - Find, replace, or delete text (including hidden text) |
| 61 | + - Get word and character counts |
| 62 | + |
| 63 | +## Additional Utilities |
| 64 | + |
| 65 | +- **Repair** corrupted or damaged PDF files. |
| 66 | +- **Generate PDF** from TXT or image files. |
| 67 | +- **Optimize** document resources and structure. |
| 68 | +- **Product diagnostics**: retrieve library info, version, and capabilities. |
| 69 | + |
| 70 | +## Platform Independence |
| 71 | + |
| 72 | +Aspose.PDF for Node.js via C++ is a WebAssembly-based library that can be used to create applications in Node.js environment. |
| 73 | +The library was written in C++ and does not require additional runtime environments. |
| 74 | + |
| 75 | +## Getting Started with Aspose.PDF for Node.js via C++ |
| 76 | + |
| 77 | +Are you ready to give Aspose.PDF for Node.js via C++ a try? |
| 78 | + |
| 79 | +- Execute `npm install asposepdfnodejs` in Terminal in Visual Studio Code or in another console. |
| 80 | + |
| 81 | +Prefer to work with the source code directly? |
| 82 | + |
| 83 | +- Execute `git clone https://github.com/aspose-pdf/Aspose.PDF-for-Node.js-via-CPP.git`, then `cd Aspose.PDF-for-Node.js-via-CPP` and `npm install` to set up the project locally. |
| 84 | + |
| 85 | +## Setting up |
| 86 | + |
| 87 | +- You need arial.ttf and times.ttf fonts to perform basic operations |
| 88 | + |
| 89 | +## Extract Text From Whole PDF |
| 90 | + |
| 91 | +**CommonJS**: |
| 92 | +```js |
| 93 | +const AsposePdf = require('asposepdfnodejs'); |
| 94 | +const pdf_file = 'Aspose.pdf'; |
| 95 | +AsposePdf().then(AsposePdfModule => { |
| 96 | + /*Extract text from a PDF-file*/ |
| 97 | + const json = AsposePdfModule.AsposePdfExtractText(pdf_file); |
| 98 | + console.log("AsposePdfExtractText => %O", json.errorCode == 0 ? json.extractText : json.errorText); |
| 99 | +}); |
| 100 | +``` |
| 101 | +**ECMAScript/ES6**: |
| 102 | +```js |
| 103 | +import AsposePdf from 'asposepdfnodejs'; |
| 104 | +const AsposePdfModule = await AsposePdf(); |
| 105 | +const pdf_file = 'Aspose.pdf'; |
| 106 | +/*Extract text from a PDF-file*/ |
| 107 | +const json = AsposePdfModule.AsposePdfExtractText(pdf_file); |
| 108 | +console.log("AsposePdfExtractText => %O", json.errorCode == 0 ? json.extractText : json.errorText); |
| 109 | +``` |
| 110 | + |
| 111 | +## Save PDF as Office Formats |
| 112 | + |
| 113 | +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. |
| 114 | + |
| 115 | +Give the following snippet a try with your samples: |
| 116 | + |
| 117 | +**CommonJS**: |
| 118 | + |
| 119 | +```js |
| 120 | +const AsposePdf = require('asposepdfnodejs'); |
| 121 | +const pdf_file = 'Aspose.pdf'; |
| 122 | +AsposePdf().then(AsposePdfModule => { |
| 123 | + /*Convert a PDF-file to DocX and save the "ResultPDFtoDocX.docx"*/ |
| 124 | + const json = AsposePdfModule.AsposePdfToDocX(pdf_file, "ResultPDFtoDocX.docx"); |
| 125 | + console.log("AsposePdfToDocX => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText); |
| 126 | +}); |
| 127 | +``` |
| 128 | + |
| 129 | +**ECMAScript/ES6**: |
| 130 | + |
| 131 | +```js |
| 132 | +import AsposePdf from 'asposepdfnodejs'; |
| 133 | +const AsposePdfModule = await AsposePdf(); |
| 134 | +const pdf_file = 'Aspose.pdf'; |
| 135 | +/*Convert a PDF-file to DocX and save the "ResultPDFtoDocX.docx"*/ |
| 136 | +const json = AsposePdfModule.AsposePdfToDocX(pdf_file, "ResultPDFtoDocX.docx"); |
| 137 | +console.log("AsposePdfToDocX => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText); |
| 138 | +``` |
| 139 | + |
| 140 | +[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-for-Node.js-via-CPP/) | [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) |
0 commit comments