我正在尝试使用dompdf在pdf中转换我的report.php,但我一直收到错误。如何解决此错误请协助。以下是我得到的错误: -
警告:require_once(dompdf / C:\ tmpp \ php \ PEAR):无法打开流: C:\ xampp \ htdocs \ check \ dompdf \ report.php中没有此类文件或目录 在第15行
致命错误:require_once():无法打开所需的'dompdf / C: mpp \ php \ PEAR'(include_path ='C:\ xampp \ php \ PEAR')in 第15行的C:\ xampp \ htdocs \ check \ dompdf \ report.php
答案 0 :(得分:0)
对不起男人,但我觉得它不像那样
试试这个
<?php
$fileToConvert = "C:/example/myfile.html"; // Or .php
if(!file_exists($fileToConvert)) {
echo "File not found";
exit;
}
/** Now, We must read php file */
$contentOfFileToConvert = readfile($fileToConvert);
/** Load Dompdf library */
require_once 'C:/libraries/.../dompdf/autoload.inc.php';
/** Reference to Dompdf namespace */
use Dompdf\Dompdf;
/** instantiate and use the dompdf class */
$DOMPDF = new Dompdf();
/** Files Content must be in HTML */
$DOMPDF->loadHtml($contentOfFileToConvert);
/** ... OTHER OPTIONS */
$DOMPDF->setPaper('A4', 'landscape');
/** AUTOMATIC DOWNLOAD DIALOG */
$DOMPDF->stream(
/** Filename that You want */
'my_document.pdf',
/**
* 'compress' = > 1 (=default) or 0:
* Apply content stream compression
*
* 'Attachment' => 1 (=default) or 0:
* Set the 'Content-Disposition:' HTTP header to 'attachment'
* (thereby causing the browser to open a download dialog)
*/
$options = array(
'compress' => true, //or false
'attachment' => true //or false
)
);
/** Options array is not necessary */
$DOMPDF->stream(
/** Filename that You want */
'my_document.pdf'
);