I'm new here. I mainly deal with backend programming (OOP PHP) but I also have to do some frontend stuff. I'm currently working on creating a PDF (client side) with html2canvas and pdfmake. In this PDF I have to include 2 dynamically loaded graphics (canvas js), table and map (leaflat js). So far everything went well (I did everything else) but I do not know how to add the second graphic to my PDF.
CODE:
html2canvas($("#chartdiv"), {
onrendered: function(canvas) {
var myImage = canvas.toDataURL("image/png");
//here i can add table, map and variable myImage to my docdefinition content and call pdfMake.createPdf(docDefinition).download(); to download the pdf.
}
});
//i want to use variable myImage here.
This work fine, but how i can use variable myImage outside the function to add in my docdefinition content to create my pdf with pdfmake? I'm trying to define global variable but not work. I do not use jspDF because I can not use Cyrillic there and my PDF contains Cyrillic.
Thanks a lot for the help!
you assigned the var inside the function,better You'll have to assign it that can accessible from the outside.
var myImage;
html2canvas($("#chartdiv"), {
onrendered: function(canvas) {
myImage = canvas.toDataURL("image/png");
//here i can add table, map and variable myImage to my docdefinition content and call pdfMake.createPdf(docDefinition).download(); to download the pdf.
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.