在共享主机上时从HTML页面生成PDF文件 [英] Generate PDF file from HTML page while on shared hosting
问题描述
我在主机上启用扩展等的访问权限非常有限,但希望通过PHP从HTML页面(带有CSS/图像)生成PDF.
I have very limited access to enable extensions etc on my hosting but am looking to generate a PDF from an HTML page (with css/images) through PHP.
有什么主意,我想如何通过接近零的CL访问量来实现这一目标? 最好不要依赖服务(因为我会长期使用它).
Any ideas how I can achieve this with next to zero CL access etc? Preferable not a "hack" / relient on a service (as I'll be looking to use this long term).
推荐答案
生成HTML呈现为PDF时,请在单个$ html变量中创建该HTML.这可用于传递到任何pdf渲染API.
When generating HTML to render in to the PDF, create that HTML in single $html variable. This can be used to pass to the any of the pdf rendering api's.
广泛使用的API是DOM PDF,html2pdf,html2ps.
Widely used API's are DOM PDF, html2pdf, html2ps.
诸如html2ps之类的一些API也支持外部css&类也.一些必需的内联CSS.
Some of the API's like html2ps also supports the external css & classes also. Some required inline CSS.
我使用了DOM PDF& html2ps
I have used DOM PDF & html2ps
这是链接
这篇关于在共享主机上时从HTML页面生成PDF文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!