Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Last active September 20, 2024 10:11
How to Convert Word to PDF using Node.js
// Convert the Word Document to PDF format using Node.js
// Load the source DOCX file
const converter = new groupdocs.conversion.Converter("sample.docx");
// Set the convert options for PDF format
const options = new groupdocs.conversion.PdfConvertOptions();
// Convert to PDF format
converter.convert("converted.pdf", options);
// Convert the specific pages of a Password Protected Word Document to PDF format using Node.js
const loadOptions = new groupdocs.conversion.WordProcessingLoadOptions()
loadOptions.setPassword("12345");
const converter = new groupdocs.conversion.Converter('sample.docx')
const convertOptions = new groupdocs.conversion.PdfConvertOptions();
convertOptions.setPageNumber(2);
convertOptions.setPagesCount(1);
// convertOptions.setRotate(groupdocs.conversion.Rotation.On180);
convertOptions.setDpi(300);
convertOptions.setWidth(1024);
convertOptions.setHeight(768);
converter.convert("converted.pdf", convertOptions);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment