5
我有一個來自MySQL DB的動態加載,並且我的頁面URL是http://localhost/far/contractview?ID=137。當我試圖將此頁面轉換爲PDF格式時,出現了一些錯誤,我不知道該如何操作才能將此頁面轉換爲按鈕單擊時的PDF。php將頁面轉換爲pdf加載ID
我在下面列入了我的代碼。我正在使用mpdf
。
<?php
require("mpdf60/mpdf.php");
$mpdf=new mPDF('application/pdf','Letter-L','','',15,10,16,10,10,10);//A4 page in portrait for landscape add -L.
$mpdf->debug = true;
//$mpdf->allow_output_buffering = true;
//$mpdf->SetHeader('|Your Header here|');
//$mpdf->setFooter('{PAGENO}');// Giving page number to your footer.
$mpdf->useOnlyCoreFonts = true; // false is default
$mpdf->SetDisplayMode('fullpage');
// Buffer the following html with PHP so we can store it to a variable later
ob_start();
?>
<?php
//include "contractview.php";
include_once "users.php";
//This is your php page ?>
<?php
$html = ob_get_contents();
ob_end_clean();
// send the captured HTML from the output buffer to the mPDF class for processing
$mpdf->WriteHTML($html);
//$mpdf->SetProtection(array(), 'user', 'password'); uncomment to protect your pdf page with password.
$mpdf->Output();
exit;
?>
在此先感謝。
什麼是 「一些錯誤」,你得到? – bIgBoY
SCREAM:錯誤抑制忽略警告:include_once(contractview?ID = 137)[function.include-once]:未能 打開流:結果太大在C:\ wamp \ www \ far \ php-to-pdf.php 15行 – user2989676
這裏需要php-to-pdf.php的代碼。正如你所看到的,你試圖包含一個url而不是一個文件。 – bIgBoY