dolanmiu / docx

Easily generate and modify .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.
https://docx.js.org/
MIT License
4.23k stars 480 forks source link

How to convert the Word Document to PDF? #188

Closed sleepinzombie closed 5 years ago

sleepinzombie commented 5 years ago

Based on what I saw on the official documentation of docx, version 4 and up does not support the 'export the pdf' functionality.

Actually I have to save both word documents and PDF. I successfully converted the .docx file but not being able to export to pdf.

Do you have any other alternative I can use to successfully convert and save the docx to pdf?

dolanmiu commented 5 years ago

Yes, you can check the source of the old pdf packer here:

https://github.com/dolanmiu/docx/blob/5f594a822fc2b4a89e2c82c5ca255f9ac05eefa7/src/export/packer/pdf-convert-wrapper.ts

As you can see, its a cheat, and only calls an endpoint, which you can do yourself

dolanmiu commented 5 years ago

Closing because PDF creation is no longer in scope

plutext commented 5 years ago

For anyone looking, there is now https://www.npmjs.com/package/@nativedocuments/docx-wasm which performs the conversion locally. Freemium model.