@groupdocs/groupdocs.conversion
Version:
Document conversion API for Node.js (powered by Java) to convert back and forth between the most popular document and image formats, including PDF, Word, Excel, PowerPoint, OpenDocument documents, e-mail messages, images and many more in one package.
221 lines (153 loc) • 8.53 kB
Markdown
Document conversion API for Node.js (powered by Java) to convert back and forth between the most popular document and image formats, including PDF, Word, Excel, PowerPoint, OpenDocument documents, e-mail messages, images and many more in one package.
## Quick links
- [Product Home](https://products.groupdocs.com/conversion/nodejs-java/)
- [Release Notes](https://releases.groupdocs.com/conversion/nodejs-java/release-notes/)
- [Documentation](https://docs.groupdocs.com/conversion/nodejs-java/)
- [System Requirements](https://docs.groupdocs.com/conversion/nodejs-java/system-requirements/)
- [Installation Guide](https://docs.groupdocs.com/conversion/nodejs-java/installation/)
- [Support](https://forum.groupdocs.com/)
- [Pricing](https://purchase.groupdocs.com/pricing/conversion/nodejs-java/)
## Key Features
- Convert whole documents to desired target formats.
- Convert specific document page(s) or page ranges.
- Auto-detect source document format on the fly without requiring the file extension.
## Supported Formats
### Documents & Office
- **PDF:** PDF (versions 1.3, 1.4, 1.5, 1.6, 1.7)
- **Word Processing:** DOC, DOCM, DOCX, DOT, DOTM, DOTX, MD, RTF, TXT
- **Spreadsheet:** XLS, XLSX, XLSB, XLTX, XLTM, XLSM, CSV, NUMBERS, ODS
- **Presentation:** PPT, PPTX, PPS, PPSX, POTM, POTX, POT, PPSM, PPTM
- **OpenOffice:** ODS, ODP, OTP, ODT, OTT
### Other Formats
- **Images:** JPG, PNG, SVG, BMP, GIF, AI, DJVU, ICO, TIFF
- **CAD:** CF2, DGN, DWFX, DWT
- **Compression:** 7Z, GZIP, RAR, ZIP
- **Database:** LOG, NSF, SQL
- **Diagram:** VDX, VSD, VSDM, VSDX
- **eBook:** AZW3, EPUB, MOBI
- **Email & Outlook:** EML, EMLX, MSG, PST
- **Font:** CFF, EOT, OTF, TTF
- **Page Description Language:** CGM, PS, SVG, XPS
- **Project Management:** MPP, MPT, XER
- **Publisher:** PUB
- **Web:** HTML, JSON, VDW, XML
## Getting Started
### Prerequisites
- Node.js (LTS recommended)
- Java Runtime Environment (JRE) 8 or later
- Windows, Linux, or macOS
### Installation
Install the package from npm:
```bash
npm i @groupdocs/groupdocs.conversion
```
For detailed setup instructions, see the [System Requirements](https://docs.groupdocs.com/conversion/nodejs-java/system-requirements/) and [Installation](https://docs.groupdocs.com/conversion/nodejs-java/installation/) documentation topics.
### Use cases
Below are simple Node.js snippets that demonstrate typical use cases: converting a DOCX to PDF, converting PDF to PDF/A, and converting only specific pages of a document.
#### Convert DOCX to PDF
This code example shows how to convert a Word document (DOCX) to a PDF file with default conversion options.
```js
'use strict';
// Require dependencies
const groupdocs = require('@groupdocs/groupdocs.conversion');
const path = require('path');
// Apply license if you have one (optional for evaluation).
const licensePath = path.resolve(__dirname, 'GroupDocs.Conversion.lic');
const license = new groupdocs.License();
license.setLicense(licensePath);
// Create a converter for the source document.
const converter = new groupdocs.Converter('source.docx');
// Set up PDF conversion options and run the conversion.
const convertOptions = new groupdocs.PdfConvertOptions();
converter.convert('converted.pdf', convertOptions);
// Exit the process
process.exit(0);
```
#### Convert PDF to PDF/A
This code example shows how to convert a regular PDF document to a PDF/A-compliant PDF.
```js
'use strict';
// Require dependencies
const groupdocs = require('@groupdocs/groupdocs.conversion');
const path = require('path');
// Apply license if you have one (optional for evaluation).
const licensePath = path.resolve(__dirname, 'GroupDocs.Conversion.lic');
const license = new groupdocs.License();
license.setLicense(licensePath);
// Create a converter for the source document.
const converter = new groupdocs.Converter('source.pdf');
// Set the format to PDF/A-compliant PDF
const pdfOptions = new groupdocs.PdfOptions();
pdfOptions.setPdfFormat(groupdocs.PdfFormats.PdfA_1A);
// Set the convert options
const convertOptions = new groupdocs.PdfConvertOptions();
convertOptions.setPdfOptions(pdfOptions);
// Convert the document
converter.convert('converted_pdfa.pdf', convertOptions);
// Exit the process
process.exit(0);
```
#### Convert Specific Pages
This code example shows how to convert only selected pages of a Word document (DOCX) to a PDF document.
```js
'use strict';
// Require dependencies
const groupdocs = require('@groupdocs/groupdocs.conversion');
const path = require('path');
// Import java array list
const java = require('java');
const ArrayList = java.import('java.util.ArrayList');
// Apply license if you have one (optional for evaluation)
const licensePath = path.resolve(__dirname, 'GroupDocs.Conversion.lic');
const license = new groupdocs.License();
license.setLicense(licensePath);
// Create a converter for the source document
const converter = new groupdocs.Converter('source.docx');
// Set pages to convert
const pages = new ArrayList();
pages.add(1);
pages.add(2);
pages.add(3);
// Set the convert options
const convertOptions = new groupdocs.PdfConvertOptions();
convertOptions.setPages(pages);
// Convert pages 1, 2, and 3 to PDF
converter.convert('converted_pages_1_2_3.pdf', convertOptions);
// Exit the process
process.exit(0);
```
## Troubleshooting
- **Download during installation fails (corporate proxy/firewall)**: Ensure your environment allows downloading the required JAR during `postinstall`. If needed, download the file manually to the `lib/` directory as described in the [Installation Guide](https://docs.groupdocs.com/conversion/nodejs-java/installation/).
- **Java not found**: Make sure Java (JRE 8+) is installed and available on your system `PATH`.
- **Permission issues when writing output files**: Verify your process has write access to the target directory.
## Licensing
For testing without trial limitations, you can request a 30-day Temporary License:
- Visit the [Get a Temporary License](https://purchase.groupdocs.com/temp-license/104266) page
- Login with your company email address
- Request a temporary license and get it in your mailbox
After you receive the license file, save it locally and use it in your application as follows:
```js
'use strict';
const groupdocs = require('@groupdocs/groupdocs.conversion');
// Apply license
const license = new groupdocs.License();
license.setLicense('GroupDocs.Conversion.lic');
```
This product is licensed under the GroupDocs End User License Agreement (EULA). For pricing information, visit the [GroupDocs.Conversion for Node.js via Java pricing page](https://purchase.groupdocs.com/pricing/conversion/nodejs-java/).
## Support
GroupDocs provides unlimited free technical support for all of its products. Support is available to all users, including evaluation. The support is provided at [Free Support Forum](https://forum.groupdocs.com/), [Paid Support Helpdesk](https://helpdesk.groupdocs.com/) and [Paid Consulting](https://consulting.groupdocs.com/).
### Free Support Forum
The [GroupDocs Free Support Forum](https://forum.groupdocs.com/) is available to all users and provides:
- Human support by the product team
- No time limitations on support requests
- Access to historical solutions and discussions
### Paid Support Helpdesk
The [Paid Support Helpdesk](https://helpdesk.groupdocs.com/) offers:
- Higher priority response times
- Dedicated support team
- Extended support hours
- Priority issue resolution
### Paid Consulting
We can work together with you on your project and develop a part or complete application. If you need new features in the existing GroupDocs product or to create API for new file formats, send us a request at [consulting.groupdocs.com/contact](https://consulting.groupdocs.com/contact/).
---
| [Product Home](https://products.groupdocs.com/conversion/nodejs-java) | [Documentation](https://docs.groupdocs.com/conversion/nodejs-java/) | [Blog](https://blog.groupdocs.com/category/conversion/) | [Code Samples](https://github.com/groupdocs-conversion/GroupDocs.Conversion-for-Node.js-via-Java) | [Free Support](https://forum.groupdocs.com/c/conversion) | [Temporary License](https://purchase.groupdocs.com/temp-license/104266) | [Pricing](https://purchase.groupdocs.com/pricing/conversion/nodejs-java/) |