Nodejs: Convert Doc to PDF

Andi Giga picture Andi Giga · Sep 6, 2016 · Viewed 19.9k times · Source

I found some repos, which do not look as they are still maintained:

I tried the approach with libreoffice, but the pdf output is so bad, that it is not useable (text on diff. pages etc.).

If possible I would like to avoid starting any background processes and/or saving the file on the server. Best would be solution where I can use buffers. For privacy reasons, I cannot use any external service.

doc buffer -> pdf buffer

Question:

How to convert docs to pdf in nodejs?

Answer

yumaa picture yumaa · Feb 26, 2020

For those who might stumble on this question nowadays:

There is cool tool called Gotenberg — Docker-powered stateless API for converting HTML, Markdown and Office documents to PDF. It supports converting DOCs via unoconv.

And I am happen to be an author of JS/TS client for Gotenberg — gotenberg-js-client

I welcome you to use it :)