Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

377
Visualizações
How to generate pdf from docx - NodeJS + TypeScript

I'm trying to generate a PDF from a previously generated DOCX file in NodeJS. I'm using NestJS and TypeScript. I have tried many ways, but everything fails:

  • @nativedocuments/docx-wasm: NativeDocuments isn't working anymore.
  • word2pdf: Is archived at github, and unavailable at npm.
  • docx-pdf: Generates an unstyled pdf. It removes my tables, indentation, justified text, etc.
  • libreoffice-convert: Throws a window error: The application cannot be started. The configuration file "C:/Program Files/LibreOffice/program/bootstrap.ini" is corrupt (But LibreOffice software is working with no problem).

Do you know some workaround to the problems I got with any of the previously mentioned docx to pdf alternatives? Or maybe some other alternative that I can use (For free, please)?

Thank you in advance!

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

The best I know about is using Libreoffice. You don't really need a wrapper library for that.

You can just execute libreoffice directly using exec:

const { exec } = require("child_process");

exec("libreoffice --headless file.xyz", (error, stdout, stderr) => {
    if (error) {
        console.log(`error: ${error.message}`);
        return;
    }
    if (stderr) {
        console.log(`stderr: ${stderr}`);
        return;
    }
    console.log(`stdout: ${stdout}`);
});

You'll need to first write your DOCX to a file somewhere on the disk where Libreoffice would be able to open it, and the resulting PDF would be written on the disk as well - then you can load it into Node with fs.

about 4 years ago · Juan Pablo Isaza Relatório

0

I've had success using Puppeteer to render PDFs from HTML documents. If you could manage to transform your DOCX file into HTML, this might be a viable option. It looks like there are options available to do so, but I can't vouch for them.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda