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

143
Visualizações
Cómo enviar PDF a la transmisión

Intento generar un correo con un archivo PDF adjunto. ¿Cómo escribo el PDF directamente en un archivo adjunto? Probé este:

 var pdf = printer.createPdfKitDocument(docDefinition); const content = new stream.Writable(); pdf.pipe(content); pdf.end(); let mail = await transporter.sendMail({ from: sender, to: recipient, subject: "Subject of Mail", text: "Here is the latest Overview", attachments: [{ filename: 'Overview.pdf', contentType: 'application/pdf', content: content }] }); node:internal/streams/writable:589 throw new ERR_METHOD_NOT_IMPLEMENTED('_write()'); ^ Error [ERR_METHOD_NOT_IMPLEMENTED]: The _write() method is not implemented at new NodeError (node:internal/errors:371:5) at Writable._write (node:internal/streams/writable:589:11) at writeOrBuffer (node:internal/streams/writable:390:12) at _write (node:internal/streams/writable:331:10) at Writable.write (node:internal/streams/writable:335:10) at PDFDocument.ondata (node:internal/streams/readable:777:22) at PDFDocument.emit (node:events:390:28) at PDFDocument.Readable.read (node:internal/streams/readable:550:10) at flow (node:internal/streams/readable:1035:34) at resume_ (node:internal/streams/readable:1016:3) { code: 'ERR_METHOD_NOT_IMPLEMENTED' }

Funciona bien cuando guardo el PDF en un archivo temporal, pero me gusta evitar eso:

 let filePath = tmp.tmpNameSync({ postfix: ".pdf" }); var pdf = printer.createPdfKitDocument(docDefinition); pdf.pipe(fs.createWriteStream(filePath)); pdf.end(); let mail = await transporter.sendMail({ ... attachments: [{ filename: 'Overview.pdf', path: filePath }] }); fs.unlink(filePath, err => { if (err) logger.error(err) } );
about 4 years ago · Juan Pablo Isaza
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