如何让jsPDF转换大文本?

How to make jsPDF convert big text?

我正在使用 jsPDF 将 html 转换为 pdf。当一个页面有很多文本时,我得到一个空白的 pdf 或一个没有内容的灰色页面sanf data: in url

我在控制台中没有错误。

如何让它正确打印pdf?

要转换为 pdf,我使用此代码:

     $(document).ready(function(){
     var specialElementHandlers = {
         '#editor': function (element,renderer) {
             return true;
         }
     };
     $('#topdf').click(function () {

      var doc = new jsPDF();

      var specialElementHandlers = {
        '#editor': function(element, renderer){
            return true;
        }
      };

      doc.fromHTML($('.post-content p').get(0), 15, 15, {
        'width': 170, 
        'elementHandlers': specialElementHandlers
      });

       doc.output("dataurlnewwindow");
     });
 });

问题是 URL 长度限制为 2000 个字符(此处更多:What is the maximum length of a URL in different browsers?), so I suggest you to use doc.output('save', 'filename.pdf') but this have limitation (more: How to open generated pdf using jspdf in new window