duanfu1945 2016-11-15 15:47
浏览 26

用PHP创建PDF文件

I need to create a temp PDF file in PHP, and read it out. But I got the error, it means there is no file existing.

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

My code as follows:

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");

Thanks for any help and comment.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 目详情-五一模拟赛详情页
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line