简体   繁体   English

将php表打印为pdf

[英]Print php table to pdf

I have a table generated by PHP and a lot of MySQL query. 我有一个由PHP生成的表和许多MySQL查询。 It looks like this: 看起来像这样:

在此处输入图片说明

I need to print this table to a PDF file. 我需要将此表打印为PDF文件。 I've tried TCPDF and it works great but it doesn't support external CSS. 我已经尝试过TCPDF,它的效果很好,但是它不支持外部CSS。 I've tried to JSON the item in my table to send them with POST to the page but it doesn't work. 我尝试对表中的项目进行JSON处理,以通过POST将其发送到页面,但无法正常工作。 So, the question is, there's any simple (I really hope for it) to send via a button all the table and print it into PDF? 因此,问题是,有什么简单的方法(我真的希望如此)通过按钮将所有表格发送并打印成PDF吗?

If you want to have a "nice looking" conversion, you can use wkhtmltopdf . 如果要进行“漂亮”转换,可以使用wkhtmltopdf It uses Webkit engine to generate PDF from an HTML source. 它使用Webkit引擎从HTML源生成PDF。 It is distributed both, as sourcecode and as binnary images for common OS. 它既作为源代码发行,也作为普通操作系统的二进制映像分发。

If you can execute binaries in your host, I'd give it a try. 如果您可以在主机中执行二进制文件,请尝试一下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM