GroupDocs.Conversion for Node.js via Java allows you to convert PDF files to PDF/A format, ensuring compliance with the PDF/A standard.
The conversion process is straightforward and requires only a few lines of code.
Convert PDF to PDF/A in JavaScript
'use strict';
// Import the package
const groupdocs = require('@groupdocs/groupdocs.conversion');
// Load the source PDF file
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 PDF to PDF/A
converter.convert("converted_pdfa.pdf", convertOptions);
// Exit the process
process.exit(0);
A common scenario is converting an entire PDF document or selected pages into a set of images. GroupDocs.Conversion for Node.js via Java can convert PDFs into image formats such as TIFF, JPG, PNG, GIF, BMP, and others.
You can select the required image format using the ImageFileType class.
Convert PDF to images in JavaScript
'use strict';
// Import the package
const groupdocs = require('@groupdocs/groupdocs.conversion');
// Load the source PDF file
const converter = new groupdocs.Converter("source.pdf");
// Set the convert options and specify the output image type
const convertOptions = new groupdocs.ImageConvertOptions();
convertOptions.setFormat(groupdocs.ImageFileType.Png);
// Convert and save converted_page_1.png, converted_page_2.png, converted_page_3.png, etc. in the output folder
converter.convert("converted_page_.png", convertOptions);
// Exit the process
process.exit(0);
You can convert specific pages or a page range from a document to the same or a different format.
The following example demonstrates how to convert pages 1, 2 and 3 from a DOCX file to PDF.
Convert pages 1, 2 and 3 to PDF in JavaScript
'use strict';
// Import the package
const groupdocs = require('@groupdocs/groupdocs.conversion');
// Load the source DOCX file
const converter = new groupdocs.Converter("source.docx");
// Speciry the range of pages to convert
const convertOptions = new groupdocs.PdfConvertOptions();
convertOptions.setPageNumber(1);
convertOptions.setPagesCount(3);
// Convert pages 1, 2 and 3 to PDF
converter.convert("pages_1_2_3.pdf", convertOptions);
// Exit the process
process.exit(0);