Open hmtri1011 opened 7 years ago
I needed this as well (for a microservice where I don't want to generate a lot of temporary files) but then realized it's just not the design of this library at the moment, since it invokes pdftk
with execFile and then waits for its completion.
So I forked the project and set it up to return a stream within a promise: https://github.com/jasonphillips/pdffiller-stream
Streams can be served to the client in Express (though I forget the exact syntax) so from here it should be straightforward for you to implement your response if you search those docs.
I haven't PR-ed any of that fork's work here since it feels like a slightly different goal, but am certainly open to doing so.
Tks @jasonphillips
@jasonphilips if you added streaming as an option In sure we would be open to adding it to the project
Could you make an example how to do this with express ? i'm a bit stuck here:
export function fillForm(req, res) {
...
return pdfFiller.fillFormWithFlatten(sourcePDF, data, shouldFlatten)
.then(outputStream => {
res.header('Content-disposition', 'inline; filename=' + 'sdfsdf.pdf');
res.header('Content-type', 'application/pdf');
console.log('done');
const streamRes = outputStream.pipe(res);
return streamRes.end();
});
}`
In README we have an example of fillForm method:
I have a question, can we have a way to handle the filled form PDF before saving it to destinationPDF path??
In my project, can I send a filled PDF to my client through REST API. Here is my code..
Any help would be appreciated, tks so much!