Jspdf: how to send through email generated pdf document..?

Created on 21 Sep 2018  路  4Comments  路  Source: MrRio/jsPDF

Thank you for submitting an issue to jsPDF. Please read carefully.

Are you using the latest version of jsPDF?

Have you tried using jspdf.debug.js?

Steps to reproduce

Ideally a link too. Try fork this http://jsbin.com/rilace/edit?html,js,output

What I saw

What I expected

Most helpful comment

pdf is generating that is not a problem. i want to take that pdf file and need to send to back end and attach with mail. i cannot take pdf file to back end .

All 4 comments

pdf is generating that is not a problem. i want to take that pdf file and need to send to back end and attach with mail. i cannot take pdf file to back end .

pdf is generating that is not a problem. i want to take that pdf file and need to send to back end and attach with mail. i cannot take pdf file to back end .

i've the same problem.

Solution,,
You have to send file as imageUrl from font end canvas.toDataURL('image/png')..

In back end buf = new Buffer(req.body.imageBinary.replace(/^data:image\/\w+;base64,/, ""), 'base64'); create buffer of base 64, as image or pdf format..

var data = {
Key: fileName,
Body: buf,
ContentEncoding: 'base64',
ContentType: 'pdf',
ACL: "public-read-write"
};
the data objec will be pdf file. you can store or can attache in email

Solution,,
You have to send file as imageUrl from font end canvas.toDataURL('image/png')..

In back end buf = new Buffer(req.body.imageBinary.replace(/^data:image/\w+;base64,/, ""), 'base64'); create buffer of base 64, as image or pdf format..

var data = {
Key: fileName,
Body: buf,
ContentEncoding: 'base64',
ContentType: 'pdf',
ACL: "public-read-write"
};
the data objec will be pdf file. you can store or can attache in email

Frontend (Angular):
var data = pdf.output('blob');
var formData = new FormData();
formData.append("pdf", data, "myfile.pdf");

  var request = new XMLHttpRequest();
  request.open("POST", "http://localhost:3000/caseforms", true);
  request.responseType = "blob";
  request.send(formData);

backend(Nodejs) i've got gibberish raw file:
%PDF-1.3
%锟竭拷
3 0 obj
< /Parent 1 0 R
/Resources 2 0 R
/MediaBox [0 0 595.28 841.89]
/Contents 4 0 R

>
endobj
4 0 obj
<<
/Length 10

How to send a file or how to convert pdf file in backend.
Thanks for quick response..

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sajesh1985 picture sajesh1985  路  5Comments

liftarn picture liftarn  路  5Comments

baluMallisetty picture baluMallisetty  路  4Comments

glaier picture glaier  路  3Comments

mellisa0109 picture mellisa0109  路  3Comments