douying8666 2009-01-18 07:01
浏览 45
已采纳

客户端报告从PHP Web应用程序打印

I was looking for a solution for client side printing of reports and pre formatted forms from a PHP web based app. Note that these are not printing of HTML pages. Rather nicely aligned fixed formated Receipts, Order Forms, Ledger etc.

Something that I have though of.

Using PDF: Is there a simple one click way to print the report from client side? The obvious choice of opening the PDF in a window, then select File -> Print seems too cumbersome.

Using Flash: I saw some site providing single click printing through flash. Not sure what's working in the background. Any insight on this regard will be helpful.

Active-X/Silverlight(?): I won’t want to constraint my users on IE only. But this one-click printing requirement is so rigid that I would rather switch to MS only platforms if it achieves the task.

Note that it’s ok for the single click to bring up the print dialog box and user clicking a second time for printing. But any more complexity than that is a disadvantage.

  • 写回答

3条回答 默认 最新

  • dongwen3410 2009-01-18 09:11
    关注

    If the format is so rigid you need a format like PDF. HTML/CSS is so variable you'll never get it the same on all browsers. Plug Web pages have no real concept of pages (although there is some support for things like CSS print media styling).

    Also not all people actually have a printer. Trying to force something to be printed is really the wrong approach and will generally put some of your customers off.

    The minimal solution is to create a receipt page with the emdia print CSS to make it appear responable most of the time.

    If that's not enough you need to go PDF. Unfortunately that then becomes hard as this question regarding HTML+CSS to PDF conversion illustrates. PrinceXML does an outstanding job at this conversion but it's not cheap. Html2PDF is the best of the open source bunch but has issues (see that answer for more detail). I've had this same problem in the Java space and for invoices there ending up using Jasper Reports. I haven't really seen an equivalent reporting solution for PHP though. Python has reportlab, which seems a likely candidate for doing that kind of job too.

    Perhaps your best option is to generate the PDF directly. It's a bit more tedious but it avoids the many pitfalls of HTML to PDF conversion. This tutorial (Part 2) explains how.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容