简体   繁体   English

下载pdf格式不正确

[英]download pdf format not proper

Please check the link https://jsfiddle.net/dhaileytaha/1wmk9gsq/14/ 请检查链接https://jsfiddle.net/dhaileytaha/1wmk9gsq/14/

<script>
 /*Download option*/
var doc = new jsPDF();
    var specialElementHandlers = { 
 '#editor': function (element, renderer) {
        return true;
    }
    };
          doc.fromHTML($('#example').html(), 55, 55, {
        'width': 170,
    'elementHandlers': specialElementHandlers
    });


document.getElementById("cmd").onclick = function () {

    var pass1= "cool" ;

password=prompt('Please enter your password to Print this page!',' ');

if (password==pass1)
{ 
       doc.save('target-file.pdf');
   } else {
       window.alert('Sorry! You are not Authorsised');   
   }
 }

</script>

it is a datatable. 它是一个数据表。 I am able to print it in proper format but not able to download in the same FORMAT as the datatable is. 我能够以正确的格式打印它,但是不能以与数据表相同的格式下载。 Please help I want the same format as of the DATATABLE in pdf form. 请帮助我获取与PDF格式的DATATABLE相同的格式。

Your jspdf resource you are using is an old one probably and does not work properly. 您正在使用的jspdf资源可能是旧资源,无法正常工作。

Another thing you should do, is wrap the content with a div tag. 您应该做的另一件事是用div标签包装内容。

I tried out your fiddle example with the following version and it works. 我用以下版本尝试了您的小提琴示例,它可以正常工作。 http://mrrio.github.io/jsPDF/dist/jspdf.debug.js http://mrrio.github.io/jsPDF/dist/jspdf.debug.js

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

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