在PHP中将HTML表格转换为PDF - DOMPDF和html2ps / pdf都不起作用 [英] HTML tables to PDF in PHP - neither DOMPDF nor html2ps/pdf are working

查看:473
本文介绍了在PHP中将HTML表格转换为PDF - DOMPDF和html2ps / pdf都不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,我一直试图将包含大型表格的HTML页面转换为PHP。这些都是CSS样式,可以有多页。



我首先尝试了DOMPDF。它很好用,直到文档不止一页。没有找到我找到的工作。要么是出错,要么是第二页上的任何元素都会被部分覆盖在第1页的内容上。我已经尝试了最新版本和我今天签出的SVN副本。



我也尝试了html2ps / pdf,它给我写入缓存目录的权限被拒绝错误,即使目录是完全可写的。系统需求测试脚本通过。服务器在IIS下运行PHP 5(不是我选择的heh)。



它们中的任何一个都可以工作,还是有一个可以实现它的库? / b>

演示/测试脚本中的错误:

警告:file_put_contents(C:\\ \\ Inetpub \wwwroot\JM\pdf\html2ps\cache/7d888258e9745b3716532ea81342daaf.css.compiled)[function.file-put-contents]:未能打开流:在C:\ Inetpub \\ \JM\pdf\html2ps\css.cache.class.php on line 33



警告:fopen(C:\ Inetpub\wwwroot\JM\pdf\html2ps\cache/unicode.lb.classes.dat)[function.fopen]:未能打开流:权限被拒绝在C:\ Inetpub\wwwroot\JM\pdf\html2ps\inline.content.builder.php on line 991



警告:flock()期望参数1是资源,布尔值在C:\Inetpub\wwwroot\JM\pdf中给出\\ html2ps\inline.content.builder.php on line 992



警告:fwrite():提供的参数不是在1011行的C:\ Inetpub \wwwroot \JM\pdf\html2ps\inline.content.builder.php中的有效流资源(此错误重复数千次)




警告:fopen(C:\Inetpub\wwwroot\JM\pdf\html2ps\cache /times.z)[function.fopen]:未能打开流:C:\Inetpub\wwwroot\JM\pdf\html2ps\pdf.fpdf.makefont.php中的权限被拒绝, code>



无法写入文件C:\ Inetpub\wwwroot\JM\pdf\html2ps\\ \\ cache / times.z

解决方案

href =http://groups.google.com/group/htmltopdf/browse_thread/thread/0c8d24914f3d93e1/4350aa9cef370037?lnk=raot =nofollow noreferrer>这里。 p>

解决方案非常简单,但很奇怪。如果这对你没有帮助,一个完整的错误信息和/或一点点的代码将帮助我帮助你。


For the longest time now I've been trying to convert HTML pages containing large tables to PHP. These are styled with CSS and can be several pages long.

I first tried DOMPDF. It works great, until a document is more than one page. None of the fixes I've found work. Either it errors out, or any element that would be even partially on the second page gets lumped over the content of page 1. I've tried both the latest release and the SVN copy I checked out today.

I also tried html2ps/pdf, and it gives me "permission denied" errors writing to the cache directory, even though the directory is fully writable. The system requirements test script passes. The server is running PHP 5 under IIS (not my choice heh).

Can either of these be convinced to work, or is there a library that can do it?

Errors from the demo/test scripts:

Warning: file_put_contents(C:\Inetpub\wwwroot\JM\pdf\html2ps\cache/7d888258e9745b3716532ea81342daaf.css.compiled) [function.file-put-contents]: failed to open stream: Permission denied in C:\Inetpub\wwwroot\JM\pdf\html2ps\css.cache.class.php on line 33

Warning: fopen(C:\Inetpub\wwwroot\JM\pdf\html2ps\cache/unicode.lb.classes.dat) [function.fopen]: failed to open stream: Permission denied in C:\Inetpub\wwwroot\JM\pdf\html2ps\inline.content.builder.php on line 991

Warning: flock() expects parameter 1 to be resource, boolean given in C:\Inetpub\wwwroot\JM\pdf\html2ps\inline.content.builder.php on line 992

Warning: fwrite(): supplied argument is not a valid stream resource in C:\Inetpub\wwwroot\JM\pdf\html2ps\inline.content.builder.php on line 1011 (this error repeats several thousand times)

Warning: fopen(C:\Inetpub\wwwroot\JM\pdf\html2ps\cache/times.z) [function.fopen]: failed to open stream: Permission denied in C:\Inetpub\wwwroot\JM\pdf\html2ps\pdf.fpdf.makefont.php on line 318

Can't write to file C:\Inetpub\wwwroot\JM\pdf\html2ps\cache/times.z

解决方案

A similar problem with html2pdf under IIS has been discussed here.

The solution was quite simple, yet weird. If this doesn't help you, a full error-message and / or a little bit of code would help me to help you.

这篇关于在PHP中将HTML表格转换为PDF - DOMPDF和html2ps / pdf都不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆