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

220
Vistas
How can I download generated PDF by html-pdf-node library, node and React JS and graphQL

I am getting response from the backend now how can I download the generated PDF from the frontend by clicking on the Export button. My Export button click handler as follows;

const handleExportProjectData = () => {
const changeStatusProjectData = JSON.stringify(project);
dataProvider
  .postRequest("ExportAllProjectChangeStatus", {
    queryType: "retrieve",
    data: { changeStatusProjectData },
  })
  .then((response) => {
    console.log(response.data, "data posted");
    saveChangeReport(response.data);
  })
  .catch((error) => {
    notify("No change status data found to export");
  });
 };

and my backend code is;

const downloadChangeStatusPDF = async (root, { changeStatusProjectData },{ user }) => {
  const html_to_pdf = require("html-pdf-node");
  let options = { format: "A4" };
  let today = new Date();
  let dd = String(today.getDate()).padStart(2, "0");
  let mm = String(today.getMonth() + 1).padStart(2, "0"); //January is 0!
  let yyyy = today.getFullYear();
  today = dd + "/" + mm + "/" + yyyy;


 let file = { content: "<h1>Welcome to html-pdf-node</h1>" };



 let generatedPDF = await html_to_pdf.generatePdf(file, options)
    .then((pdfBuffer) => {
        return JSON.stringify(pdfBuffer);
    });
 return generatedPDF;
};

I am getting the following response in my console as follows; console.log(response.data)

now my question is how can I download the generated PDF using saveChangeReport function?

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

Alhamdulillah! I have solved the problem simply by converting the buffer into base64 then converting the base64 into PDF.

about 4 years ago · Santiago Gelvez 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