galkahana / HummusJS

Node.js module for high performance creation, modification and parsing of PDF files and streams
http://www.pdfhummus.com
Other
1.14k stars 169 forks source link

Add PDFWStreamForBuffer. #386

Closed PelicanMaster closed 4 years ago

PelicanMaster commented 5 years ago

Why ?

I felt it was missing in the base package as PDFRStreamForBuffer was available. It allows full PDF buffer management.

Usage

Pass it when creating writer, access the resulting Buffer with PDFWStreamForBuffer.buffer :

let pdf = new PDFWStreamForBuffer();
let writer = createWriter(pdf);

writer.appendPDFPagesFromPDF(new PDFRStreamForBuffer(myPdfBuffer));
writer.end();

let resultingBuffer = pdf.buffer; // Here you get your PDF as a buffer