0

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.

Alimon Karim
  • 4,354
  • 10
  • 43
  • 68

2 Answers2

3
  1. You Will make your image into a Data url.
  2. Go to this link http://dopiaza.org/tools/datauri/index.php for convert your image into a url.
  3. Then follow this link http://mrrio.github.io/jsPDF/ add your data url like this.
Zong
  • 6,160
  • 5
  • 32
  • 46
karthi
  • 167
  • 2
  • 5
0

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.

hari
  • 1,874
  • 1
  • 16
  • 10