How to add Image in jspdf?

混江龙づ霸主 提交于 2019-12-12 01:43:13

问题


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:


  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.



回答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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!