I have tried this code for add a image,but here Image has been not adding with pdf.
function RunCode() {
var imgData = 'data:pubali.jpg/jpeg;';
var doc = new jsPDF();
doc.setFontSize(10);
doc.text(20, 20, 'Hello world!');
doc.text(20, 30, 'This is client-side Javascript, pumping out a PDF.');
doc.addImage(imgData, 'JPEG', 15, 40, 180, 160);
doc.output('datauri');
}
How can I add image with jspdf.
I have tried this code for add a image,but here Image has been not adding with pdf.
function RunCode() {
var imgData = 'data:pubali.jpg/jpeg;';
var doc = new jsPDF();
doc.setFontSize(10);
doc.text(20, 20, 'Hello world!');
doc.text(20, 30, 'This is client-side Javascript, pumping out a PDF.');
doc.addImage(imgData, 'JPEG', 15, 40, 180, 160);
doc.output('datauri');
}
How can I add image with jspdf.
Share Improve this question asked Jun 3, 2014 at 5:40 Alimon KarimAlimon Karim 4,46910 gold badges46 silver badges70 bronze badges 1- imgdData shuld string containing base64 encoded jpg/jpeg image file – Matko Commented Sep 3, 2015 at 11:20
2 Answers
Reset to default 3- You Will make your image into a Data url.
- Go to this link http://dopiaza/tools/datauri/index.php for convert your image into a url.
- Then follow this link http://mrrio.github.io/jsPDF/ add your data url like this.
problem is you are not find out datauri,
[1] : [http://dopiaza/tools/datauri/index.php]
click this link upload your image.find out your datauri.