2017-08-14 127 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;