Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/460.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jsPDF html导出无CSS_Javascript_Jspdf - Fatal编程技术网

Javascript jsPDF html导出无CSS

Javascript jsPDF html导出无CSS,javascript,jspdf,Javascript,Jspdf,我找到了这个,但它不支持CSS 有没有办法调整jsPDF来定制表和列表的css? 我试图使用addHTML,但如果我试图传入某个元素的id而不是整个html,那么它似乎对我不起作用 function demoFromHTML() { var pdf = new jsPDF('p', 'pt', 'letter'); var source = $('#customers')[0]; specialElementHandlers = { // elem

我找到了这个,但它不支持CSS

有没有办法调整jsPDF来定制表和列表的css? 我试图使用addHTML,但如果我试图传入某个元素的id而不是整个html,那么它似乎对我不起作用

    function demoFromHTML() {
    var pdf = new jsPDF('p', 'pt', 'letter');
    var source = $('#customers')[0];
    specialElementHandlers = {
        // element with id of "bypass" - jQuery style selector
        '#bypassme': function (element, renderer) {
            // true = "handled elsewhere, bypass text extraction"
            return true
        }
    };
    margins = {
        top: 80,
        bottom: 60,
        left: 10,
        width: 700
    };
    // all coords and widths are in jsPDF instance's declared units
    // 'inches' in this case
    pdf.fromHTML(
    source, // HTML string or DOM elem ref.
    margins.left, // x coord
    margins.top, { // y coord
        'width': margins.width, // max width of content on PDF
        'elementHandlers': specialElementHandlers
    },

    function (dispose) {
        // dispose: object with X, Y of the last line add to the PDF 
        //          this allow the insertion of new lines after html
        pdf.save('Test.pdf');
    }, margins);
}
或者你有一个更好的插件类似的建议,我可以使用。在我的应用程序中,我动态地创建了一个div,其中包含了在用户可以打印之前需要放入pdf的表和列表等信息
谢谢

谢谢,我也喜欢这种方法。仍然对jsPDF很好奇。谢谢,我也喜欢这种方法。但仍然对jsPDF感到好奇。