我需要在PHP中创建一个临时PDF文件,并将其读出来。但我得到了错误,这意味着没有文件存在。
PHP Notice: Undefined index: HTTP_HOST in /home/apache/htdocs/consreports/consrpt_conf.php on line 78 PHP Warning: fopen(/home/apache/htdocs/reports/tempt.pdf): failed to open stream: No such file or directory in /home/apache/htdocs/consreports/ids_buildsrcipxmlreport.php on line 146 PHP Warning: filesize(): stat failed for /home/apache/htdocs/reports/tempt.pdf in /home/apache/htdocs/consreports/ids_buildsrcipxmlreport.php on line 147 PHP Warning: fread() expects parameter 1 to be resource, boolean given in /home/apache/htdocs/consreports/ids_buildsrcipxmlreport.php on line 147 PHP Warning: fclose() expects parameter 1 to be resource, boolean given in /home/apache/htdocs/consreports/ids_buildsrcipxmlreport.php on line 148 PHP Warning: unlink(/home/apache/htdocs/reports/tempt.pdf): No such file or directory in /home/apache/htdocs/consreports/ids_buildsrcipxmlreport.php on line 150
我的代码如下:
passthru("htmldoc --no-localfiles --no-compression -t pdf14 --quiet --jpeg --browserwidth 1100 --webpage ".
"--color --linkcolor 000099 --bodyfont Sans-Serif --fontsize 8 ".
" --landscape --header ct --footer ..: --headfootfont Sans-Serif --headfootsize 8 --size Letter ".
" -f ".$reportdir."tempt.pdf ".
" https://".$urlbase."rpt_pdfwrapper.php?reportid=".$reportid);
//get the base64 encoded pdf file
$handle = fopen($reportdir."tempt.pdf","r");
$file_content = fread($handle,filesize($reportdir."tempt.pdf"));
fclose($handle);
$srctoprptpdf = base64_encode($file_content);
unlink ($reportdir."tempt.pdf");
感谢您提供任何帮助和评论。