dpus81500574 2014-03-11 17:33
浏览 306

从html页面生成生成pdf文件的方法?

I studied wkhtmltopdf, tcpdf mechanism to generate pdf files. wkhtmltopdf where you directly pass a .html file and it gives you the pdf where in tcpdf you need to code entire pdf.

my case is I'm having a pdf form template Which I've converted into html so user can fill that form and after i fill that template with user entered values then I'll give an option to user to download the html (user filled) file as PDF document, so template will have user entered data next to that labels.

so first

PDF template >> convert to .HTML page >> process with php echoing >> convert it back with user input to a PDF file.

I'm confused here which approach I should use.

  1. Install wkhtmltopdf on server and use it to pass .html page

problem: Everytime I need to save .html page on server and pass again it to wkhtmltopdf.

  1. using TCPDF I need to write lots of code to create pdf exactly same as template PDF docs I'm having and then using php echoing those user enterted values.

Which approach should i use If I'm expecting 1000+ users will be saving page as pdf at same time, approach which will be more easier and scalable in future.

  • 写回答

1条回答 默认 最新

  • duanfang2708 2014-03-15 08:34
    关注

    First of all - I think you should go with the HTML form to PDF approach, so that's either wkhtmltopdf or a tool that already does this for you like PDFmyFORM.

    In case you're expecting to go to 1000 saves concurrently then you definitely want to roll your own solution instead of going with an external service though.

    There are patches in the wkhtmltopdf issue list that suggest caching (see this one) and you may also want to think about whether all these forms have to be generated as PDF again. You could use APC cache to somehow cache PDFs based on the same values being filled in. That could save you a bunch of time.

    Other solutions you may want to look into are for example PhantomJS, which is a headless webkit browser too, but then based on JS - so that may reduce your server load alltogether...

    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?