Get resulting file as File or Bin data for additional using
This function created PDF and save to a file
html2pdf.makePDF(canvas, pageSize, opt);
How can I to get PDF as File, for example, if I want to send it to email?
Good question! Right now, you can't. It would be a useful feature, and I'll add it to the list of improvements to make when I revamp the API.
Hi, I have just pushed a new branch, new-api, which is ready for testing! The readme has all the information on the new API. Please let me know if there are any problems with it - I want to make sure it's stable before merging into master!
For this specific request, you could use the .output method to get a datauristring:
html2pdf().from(element).output('datauristring').then(function (val) {
// Your code to send an email with val.
});
Hi, I have just pushed a new branch, new-api, which is ready for testing! The readme has all the information on the new API. Please let me know if there are any problems with it - I want to make sure it's stable before merging into master!
For this specific request, you could use the
.outputmethod to get a datauristring:html2pdf().from(element).output('datauristring').then(function (val) { // Your code to send an email with val. });
Hi, the Above method downloads file too, i only need uristring (val). How to set it download:false
This function created PDF and save to a file
html2pdf.makePDF(canvas, pageSize, opt);How can I to get PDF as File, for example, if I want to send it to email?
@AstRonin did you find any solution for this ?
This function created PDF and save to a file
html2pdf.makePDF(canvas, pageSize, opt);How can I to get PDF as File, for example, if I want to send it to email?
@AstRonin did you find any solution for this ?
Autor wrote changes, please look. https://github.com/eKoopmans/html2pdf/issues/12#issuecomment-368236593 Sorry, but I cannot test it right now...
Hi everyone, my response last February is still valid, and should give you the file as a "data URI" string. Note it's the same solution I've posted here and other places. @khateeburrehman that code should not prompt the user to download the file, there must be something else in your code causing that.
Closing this issue as resolved by the v0.9.0 new API.
Edit: The .output() command ties into the jsPDF .output() method which can produce all sorts of different values. If you want a Blob, for instance, it's a simple change:
html2pdf().from(element).output('blob').then(function (myBlob) {
// Use myBlob however you wish...
});