Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

127
Views
PDFKit envía PDF de regreso al cliente desde Express Backend

Tengo un servidor express que tiene un punto final de generación de PDF usando PDFKit.

 this.app.post("/print", (req: Request, res: Response): void => { const header = { ...req.body }; printHandlers.execute(header).then(pdf => { res.writeHead(200, { 'Content-Type': 'application/pdf', 'Access-Control-Allow-Origin': '*', 'Content-Disposition': 'attachment; filename='+header.po_num+'.pdf' }); console.log(pdf); return res.end(pdf); }) .catch(err => console.log(err)); })

Este es el código que realmente genera el PDF:

 //creates new pdf object .then((location) => { let pdfObj = new createPDF(obj, buffer, location); //console.log(pdfObj) pdfObj.generate(); return pdfObj; })

Este es el método generar():

 generate(){ let output = new PDFGenerator(); const fileName: string = `${this.data.header.po_num}.pdf`; const stream = fs.createWriteStream(fileName) output.pipe(stream); this.generateHeaders(output); output.moveDown(); this.generateTable(output); output.end(); }

Estoy tratando de enviar el PDF de regreso al cliente, y tengo problemas para saber cómo hacerlo. ¿Usando arrayBuffer? ¿Alguna otra idea?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!