Closed hdlopes closed 6 years ago
Sorry, just noticed that there is a PR on this subject and it has to do with the bufer size. Any pointers on how to do it?
the problem is not with the buffer size. it's with PDFRStreamForBuffer. it doesnt limit its reading to its size, and this is the cause of error. problem is...it's not part of hummusJS offering. i mean, im all for user examples and plugins. don't have to be part of the main deal. but i see that this causes some problems for ppl, so i will fix the bugs, maybe do some speed improv based on my findings, and submit it to be part of the lib. stay tuned for the next lib update.
k. hummus 1.0.85 holds a version of PDFRStreamForBuffer that corrects teh problem.
Thank you Gal; I'll test it as soon as issue #268 is fixed.
Working as it should on HummusJS 1.0.86!
Thank you!
Hi,
I'm creating a node service wich reads a PDF template and fills it with some text information. To avoid reading the template in each request I'm saving it as a buffer in memory and using PDFRStreamForBuffer (contributed by Luciano Júnior in another issue) to reuse the cached buffer and write it to a new stream each time, with
hummus.createWriterToModify( new PDFRStreamForBuffer(templateCache), new hummus.PDFStreamForResponse(outStreamB))
The problem is that when using createWriterToModify to read the PDF directly from a file with hummus.PDFRStreamForFile or passing the path directly, the output PDF maintains the expected size, but when reading from the cached buffer as shown above it generates a 10MB file, even though the cached buffer has the expected size. I've included a screenshot showing the extra content after the PDF's EOF: https://github.com/hdlopes/hummusjs-test-blank/raw/master/out-screenshot.jpg
Is this a problem with PDFRStreamForBuffer or expected when using node streams and buffers? Is there something that I'm missing?
I've created a sample test project here: https://github.com/hdlopes/hummusjs-test-blank