2017-08-14 128 views
1

我想用jspdf.js脚本检查pdf文件大小。我需要在下载文件之前在屏幕上显示它。有什么可能吗?jspdf检查pdf文件大小

function demoFromHTML(x = false) { 
        var pdf = new jsPDF('p', 'pt', 'letter'); 
        source = $('#print')[0]; 

        specialElementHandlers = { 
         '#bypassme': function (element, renderer) { 
          return true 
         } 
        }; 
        margins = { 
         top: 80, 
         bottom: 60, 
         left: 40, 
         width: 522 
        }; 
        pdf.fromHTML(
         source, 
         margins.left, 
         margins.top, { 
          'width': margins.width, 
          'elementHandlers': specialElementHandlers 
         }, 

         function (dispose) { 

          if(x){ 
           pdf.output('dataurlnewwindow'); 
          }else{ 
           pdf.save('<?php the_title() ?>.pdf'); 
          } 
         }, margins 
        ); 
       } 

回答

0

我找到了一个解决方案,它非常简单。 也许有人会用它:

pdf.output().length;