Convert MS Office (Word, Excel, PowerPoint) to PDF Using JavaScript
Convert an MS Office file to a PDF document without any external third-party dependencies in a browser. WebViewer already allows you to view Office documents. The below sample shows how to convert the Office document to a PDF, without initializing WebViewer UI. (You can also check out our MS Office to PDF demo now.)
Setup
Install WebViewer by running
npm i @pdftron/webvieweror download it here.Copy
corefolder fromnode_modules/@pdftron/webviewer/public/core(if you downloaded the SDK, you will findcorefolder inWebViewer/lib/) to a location that can serve static assets. For example,publicfolder in a React app.Reference
webviewer-core.min.jsscript inindex.htmland create a JS function to perform the conversion.
Additional font resources
WebViewer will automatically use substitute fonts hosted on a web server when a font is not embedded in the source document. The fallback fonts are hosted with Apryse by default but if this is a concern, you can host the fonts on your own servers. See this FAQ for more details.
Related blogs
DOCX to PDF How to Generate DOCX and Save As a PDF (in Javascript) - 1/10/2022 How to Convert DOCX Files to PDF with Node.js - 4/24/2020
Last updated
Was this helpful?