Open brianmhunt opened 6 years ago
WriteStream should work fine with PDFStreamForResponse. I would place my suspicions first in reading, rather than writing. it might be that the buffer reading is erring. perhaps the body reading is wrong? try using the rstream to repeatedly read and write to a file...then see if it creates a valid PDF file.
Thanks @galkahana . I was pretty confident that the Buffer
was being read, as I output the content to the console, but in any case I've decided to redesign around a browser-only implementation.
(Aside, we're looking for something relatively simple in the sense of page manipulation, ala pdfassembler)
I no longer have the code to test this, so please feel free to close this issue on the basis that there's nobody to test if it passes/fails. :) I'll repost/start a new issue if we come back to this.
Thank you @galkahana !
Hi, I recently implemented downloading 5 different PDF files in a firebase cloud function and merging them together.
var finalPath = path.join(os.tmpdir(), "final.pdf")
var pdfWriter = hummus.createWriter(finalPath);
pdfWriter.appendPDFPagesFromPDF(pdf1TempPath) pdfWriter.appendPDFPagesFromPDF(pdf2TempPath) pdfWriter.appendPDFPagesFromPDF(pdf3TempPath) pdfWriter.end()
Google Cloud Storage provides its own Node.js library that allows creating read streams and write streams.
I would like to read from Google Cloud Storage a number of PDFs and append them to a new PDF that's saved back to Google Cloud Storage.
At the moment I read and convert the files into
Buffer
with (using Google's Firebase):This works fine.
However, when I try to write to a Cloud file, it runs out of memory. Here's one of the many variants I've tried:
Nobody seems to have encountered this issue on StackOverflow/google.
This workflow seems to work fine when using a memory stream (e.g. memorystream) as the
writeStream
or a file stream.Is there something I may be missing about how these tie together? Should the above work with a generic
WritableStream
or are there presumptions that have to be worked around?Many thanks!