Open wallstudios opened 5 years ago
I have been struggling with this too. Uploading is not the problem, I just upload it using
firebase.storage().bucket().upload(destinationPDF, {
destination: 'forms/' + id + "/form.pdf",
})
But then again, the real problem is
{
"errno": "ENOENT",
"code": "ENOENT",
"syscall": "spawn pdftk",
"path": "pdftk",
"spawnargs": [
"assets/u130.pdf",
"fill_form",
"/tmp/temp_data15593199237626mwrm.fdf",
"output",
"/tmp/GVdxWekDP8W3Gb1AIJptFgUigvJ3"
],
"cmd": "pdftk assets/u130.pdf fill_form /tmp/temp_data15593199237626mwrm.fdf output /tmp/GVdxWekDP8W3Gb1AIJptFgUigvJ3"
}
pdftk is not available on Firebase Cloud Functions, I'm thinking about setting up a VM but I think is too much trouble. Have you resolved spawn pdftk
by any chance?
I'm trying to implement a pdf filler within a google firebase (function) environment without much luck.
Has anyone tried this with any success?
const bucket = storage.bucket('somebucket'); const sourcefilename = '/test.pdf'; const sourcePDF = bucket.file(sourcefilename);
const filename = "test-result.pdf"; const file = bucket.file(filename); const destinationPDF = file.createWriteStream();
var data = { "last_name": "last", "first_name": "first", "date": "Jan 1, 2013", "football": "Off", "baseball": "Yes", "basketball": "Off", "hockey": "Yes", "nascar": "Off" };
const GeneratePDF = (req, res) => { console.log("here....");
pdfFiller.fillForm(sourcePDF, destinationPDF, data, function (err) { if (err) throw err; console.log("In callback (we're done)."); });
};
I think the main issue is around the need to createWriteStream to save to firebase.
Any ideas?