简体   繁体   English

使用Javascript将HTML + CSS导出为PDF

[英]Export HTML + CSS to PDF using Javascript

I want to export a part of my html code to pdf, for this I am using the following code : 我想将我的html代码的一部分导出为pdf,为此我使用以下代码:

<script language = "JAVASCRIPT">
var doc = new jsPDF();
var specialElementHandlers = {
    '#editor': function (element, renderer) {
    return true;
    }
};
$('#download').click(function () {
    doc.fromHTML($('#mytable').html(), 15, 15, {
    'width': 170,
        'elementHandlers': specialElementHandlers
    });
    doc.save('sample-file.pdf');
});
</script>

but it doesn't support CSS .. how can I export it with its style ? 但它不支持CSS ..如何以其风格导出它?

What data do you want to export? 您要导出哪些数据?

If you want to export an HTML <table> , you can take a look at this export sample provided by the Shield UI Grid widget. 如果要导出HTML <table> ,可以查看Shield UI Grid小部件提供的此导出示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM