Radiobutton is not visible properly using jsPDF

ぐ巨炮叔叔 提交于 2021-02-06 14:22:42

问题


Hello I want to generate a PDF file of specific div. For that I found , jsPDF may be usefull. I am new to jsPDF and bz googling I found lines of code that will works fine for me. jsPDF code will convert div into an image and then it will save it as a pdf. Mz problem is that I have a radio button in that div but when I convert div into PDF , design of that page will be look alike below image..

I dont know what is an exact issue. Here is code that I have written.

                var imgData = canvas.toDataURL('image/png');

                /*
                Here are the numbers (paper width and height) that I found to work. 
                It still creates a little overlap part between the pages, but good enough for me.
                if you can find an official number from jsPDF, use them.
                */
                var imgWidth = 210;
                var pageHeight = 295;
                var imgHeight = canvas.height * imgWidth / canvas.width;
                var heightLeft = imgHeight;

                var doc = new jsPDF('p', 'mm');
                var position = 0;

                doc.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight);
                heightLeft -= pageHeight;

                while (heightLeft >= 0) {
                    position = heightLeft - imgHeight;
                    doc.addPage();
                    doc.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight);
                    heightLeft -= pageHeight;
                }
                doc.save('file.pdf');

回答1:


Try changing the jspdf and canvas javscript link. i fixed it using it

https://raw.githubusercontent.com/CodeYellowBV/html2canvas/master/build/html2canvas.js

https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.3/jspdf.min.js



来源:https://stackoverflow.com/questions/37949189/radiobutton-is-not-visible-properly-using-jspdf

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