Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nodejs: Convert Doc to PDF

Tags:

node.js

pdf

doc

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

  • https://github.com/gfloyd/node-unoconv
  • https://github.com/skmp/node-msoffice-pdf ...

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?

like image 453
Andi Giga Avatar asked Sep 06 '16 10:09

Andi Giga


People also ask

How do I convert a DOCX to PDF in Python?

The following are the steps to convert a Word document to PDF in Python. Load the Word document using Document class. Convert Word document to PDF using Document. save() method.


1 Answers

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 :)

UPD:
Gotenberg has new website now — https://gotenberg.dev

like image 162
yumaa Avatar answered Sep 17 '22 17:09

yumaa