Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

233
Vistas
PDFMake Base64 generates malformed document

I'm using PDFMake to generate some PDF reports on client side. When I specify the definition for document and pass it to createPdf(DEFINITION_HERE) I get my PDF and it looks nice and shiny. But I'm saving it in the DB as Base64 encoded string and when I try to reopen it with data URI (ie: data:application/pdf;base64,JVBER...) the document is completely malformed.

My DB call looks like this:

await pdfFile.getDataUrl(async (result: string) => {
      await myServiceLayer.generatePdfReport(result, fileName, creator);
});

Anyone else had this issue with PDFMake library? Any ideas on what could be the cause of this?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

OK, so after trying different things and debugging left and right, I stumbled upon this:

https://github.com/bpampuch/pdfmake/issues/318

So I removed call to .download() on my PDF file and checked for Base64 again, now it had correct value and file looks as it should.

So in a nutshell, if we call multiple methods on PDFMake, usually something will get messed up.

I had my .download() call just before my .getBase64() as I wanted to first download the file for the user and then also store it in DB as Base64, as .download() happened .getBase64() kept on giving me Base64 output which resulted in malformed PDF file.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda