2014-01-09 42 views
2

以下是我使用dompdf顯示PDF的代碼,但錯誤未能加載PDF PDF.js v0。 8.787(build:58407cf) 消息:InvalidPDFException無法加載pdf,dompdf錯誤 - > PDF.js v0.8.787(build:58407cf)消息:InvalidPDFException

表名是acad_act,數據庫名是pbas_db。數據庫連接的詳細信息存儲在db_connect.php中。任何幫助將是明顯的

<?php 
      include('db_connect.php'); 
      require 'dompdf/dompdf_config.inc.php'; 

    $sqlinv="SELECT * FROM acad_act"; 
    $res_inv = mysql_query($sqlinv) or die(mysql_error()); 
    while ($sql3=mysql_fetch_array($res_inv)) { 
      $inv_id = $sql3['User_id']; 
      $date = $sql3['Year']; 
      $cname = $sql3['Gen_Info_AQ']; 
      $subtotal = $sql3['Gen_Info_NOC']; 
      $disc = $sql3['Gen_Info_Place']; 
      $subtotal2 = $sql3['Gen_Info_Duration']; 
      $tax = $sql3['Gen_Info_SA']; 
      $gtotal = $sql3['Gen_Info_Aqyear']; 
    } 

    $dompdf= new DOMPDF(); 

    $html .="<html> 
     <head> 
     <style> 
    body { 
     font-family: arial; 
     font-size: 13px; 
    } 
    table { 
     width: 100%; 
     border-collapse: collapse; 
    } 
    th { 
     font-weight: bold; 
     font-size: 14px; 
     border: 1px solid #333333; 
    } 
    tr { 
     width: 100%; 
    } 
    td { 
     border: 1px solid #333333; 
     text-align: center; 
     padding: 10px; 
     font-weight: normal!important; 
    } 
    </style> 
    </head><body>"; 
    $html .=" 
    <table> 
    <thead> 
      <tr> 
      <th class=''>Sr.</th> 
      <th class=''>Particulars</th> 
      <th class=''>Size</th> 
      <th class=''>Quantity/Insertion</th> 
      <th class=''>Rate</th> 
      <th class=''>Amount</th> 
      <th class=''>Amount 2</th> 
      <th class=''>Amount 3</th> 
      </tr> 
    </thead> 
    <tbody> 
      <tr> 
      <td>" . $inv_id . "</td> 
      <td>" . $date . "</td> 
      <td>" . $cname . "</td> 
      <td>" . $subtotal . "</td> 
      <td>" . $disc . "</td> 
      <td>" . $subtotal2 . "</td> 
      <td>" . $tax . "</td> 
      <td>" . $gtotal . "</td> 
      </tr> 
    </tbody> 
    </table> 
    </body> 
    </html>"; 

    $dompdf->load_html($html); 
    $dompdf->render(); 

    $dompdf->stream("sample.pdf"); 

    exit(0); 
    ?> 
+0

而不是渲染到dompdf嘗試只是回顯$ html的價值,以確保沒有問題。或者,也可以保存PDF並在文本查看器中打開。某些非PDF內容可能已被捕獲到PDF輸出流中。 – BrianS

+0

我試着迴應$ html的內容,但它引起錯誤 帶有'需要輸入文件(即input_file _GET變量)'消息的未捕獲異常'DOMPDF_Exception'。 DOMPDF_Exception:需要輸入文件(即input_file _GET變量)。 –

+0

我也嘗試通過簡單地使用php和html在瀏覽器上顯示內容。在這種情況下,數據很好地顯示沒有任何錯誤,這意味着上述錯誤不是由於數據庫連接,它必須是由於本地主機,但無法擺脫此錯誤。 –

回答

1

該例外是由於PDF.js插件安裝在瀏覽器。 pdfjs不顯示錯誤,而是顯示不顯示錯誤的異常。只需刪除pdfjs插件,就可以看到所需的錯誤。

相關問題