Cloud Functions for Firebase - Merge multiple PDFs into one via Nodejs/Cloud Function

亡梦爱人 提交于 2021-01-27 18:58:51

问题


I'm running into an issue where I'm trying to combine a bunch of PDFs via a Cloud Function and then have that merged PDF be downloaded to the user's computer.

I have a function in my provider that calls the cloud function and passes an array of URLs that point to the pdfs like so:

  mergePDFs(pdfs) {

    // Create array of URLs that point to PDFs in Firebase storage
    let pdfArr = [];
    for(let key in pdfs) {
      pdfArr.push(pdfs[key].url);
    }

    // Call Firebase Cloud function to merge the PDFs into one
    this.http.get('https://us-central1-rosebud-9b0ed.cloudfunctions.net/mergePDFs', {

     }).subscribe(result => {
       console.log('merge result?', result);
     });
  }

Has anyone had any success utilizing pdf-merge NPM module to accomplish this?

I have a basic cloud function stubbed like so:

exports.mergePDFs = functions.https.onRequest((request, response) => {
  cors(request, response, () => {
    console.log('request', request);
    response.status(200).send('test');
   })
});

Though when I try to call it, I get error code 500 just so I can see if it's being called.

Has anyone else gotten the pdf merging functionality working via nodejs/Cloud Functions for Firebase?

来源:https://stackoverflow.com/questions/44128075/cloud-functions-for-firebase-merge-multiple-pdfs-into-one-via-nodejs-cloud-fun

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!