jsPDF add chart

前端 未结 2 424
感情败类
感情败类 2021-01-21 01:02

I am using jsPDF to generate PDF documents through Appcelerator\'s Titanium. Now i need to add a simple pie chart with two segments. How could i do that in simplest way?

2条回答
  •  一整个雨季
    2021-01-21 01:07

    Maybe you can check the jsPDF site first, you can generate you image with a library (perhaps google chart), save the chart as image and then add to the PDF, using the plugin jspdf.plugin.addimage.js and some code. This is an example taken from their web site

    var imgData = 'here the jpeg image string on base64';
    var doc = new jsPDF();
    
    doc.setFontSize(40);
    doc.text(35, 25, "Octonyan loves jsPDF");
    doc.addImage(imgData, 'JPEG', 15, 40, 180, 180);
    

提交回复
热议问题