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

Get the page info Object when reading the stream from a buffer #433

Closed IgorRomanvsky closed 4 years ago

IgorRomanvsky commented 4 years ago

I have a stream that I reading from a buffer by using: const inputStream = new hummus.PDFRStreamForBuffer(buffer)

How can I get the page original page size and properties Like when Im using : var pdfReader = hummus.createReader('./TestMaterials/XObjectContent.PDF').getMediaBox()

IgorRomanvsky commented 4 years ago

Solved by doing:

    const pdfWriter = hummus.createWriterToModify(inputStream, outStream);
    const copyingContext = pdfWriter.createPDFCopyingContextForModifiedFile();
    console.log(copyingContext.getSourceDocumentParser().parsePage(0).getMediaBox());