问题
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.
回答1:
- You Will make your image into a Data url.
- Go to this link http://dopiaza.org/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.
回答2:
problem is you are not find out datauri,
[1] : [http://dopiaza.org/tools/datauri/index.php]
click this link upload your image.find out your datauri.
来源:https://stackoverflow.com/questions/24007854/how-to-add-image-in-jspdf