Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdffiller - google cloud function - question #82

Open
wallstudios opened this issue May 2, 2019 · 1 comment
Open

pdffiller - google cloud function - question #82

wallstudios opened this issue May 2, 2019 · 1 comment

Comments

@wallstudios
Copy link

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?

@studiomediaagency
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant