on ‎2014 May 05 7:21 PM
I would like to generate a pdf file having images in it using javascript. I tried jsPDF but getting some exceptions like
Uncaught ReferenceError: pageWidth is not defined,
fail to load pdf document
Could anyone show me some pointers?
Thank You
Rahul
Request clarification before answering.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Image in a pdf works, http://jsbin.com/cicoh/2/edit
check the snippet, JS Bin - Collaborative JavaScript Debugging</title> <link rel="icon" href="h...
This coverts image to data-uri. But execute it in firefox or chrome with --disable-web-security flag as there is an issue with cross domain.
Regards
Sakthivel
check this, JS Bin - Collaborative JavaScript Debugging</title> <link rel="icon" href="h... The previous one was throwing a security error due to CORS issue
Here is my code
var myImg=new Image();
myImg.src=arrData['employee'][1]['Image'];
myImg.crossOrigin ="Anonymous";
var imgData = this.getBase64Image(myImg);
var doc = new jsPDF();
doc.setFontSize(40);
doc.text(35, 25, "Test Image");
doc.addImage(myImg, 'JPEG', 15, 40, 180, 160);
doc.save("sample1.pdf");
I'm receiving the following error at 'addImage' function.
Uncaught Error: getJpegSize could not find the size of the image
Could you please help in pointing out where am I going wrong.
Thank You
| User | Count |
|---|---|
| 7 | |
| 5 | |
| 5 | |
| 4 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.