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

219
Visualizações
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 Respostas
Responde à pergunta

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