Home > Mobile >  How to create pdf file from data sent in firebase cloud function [closed]
How to create pdf file from data sent in firebase cloud function [closed]

Time:09-30

I want to generate an invoice pdf by using the firebase cloud function. It should be like upon calling cloud function from client-side, data should be sent and that data should be bind with saved HTML template. By using this template I want to generate a pdf file and share the download link with the user.

CodePudding user response:

I think this article will be helpful for your desires. Is very well described process from generating the pdf to uploading it.

After that you just need to get the file download link from Firebase Cloud Storage: Download Data via URL

storageRef.child('images/stars.jpg').getDownloadURL()
.then((url) => {
// `url` is the download URL for 'images/stars.jpg'

// This can be downloaded directly:
var xhr = new XMLHttpRequest();
xhr.responseType = 'blob';
xhr.onload = (event) => {
  var blob = xhr.response;
};
xhr.open('GET', url);
xhr.send();

// Or inserted into an <img> element
var img = document.getElementById('myimg');
img.setAttribute('src', url);
})   
.catch((error) => {
// Handle any errors
});
  • Related