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条)

报告相同问题?

悬赏问题

  • ¥30 关于#opencv#的问题:使用大疆无人机拍摄水稻田间图像,拼接成tif图片,用什么方法可以识别并框选出水稻作物行
  • ¥15 Python卡尔曼滤波融合
  • ¥20 iOS绕地区网络检测
  • ¥15 python验证码滑块图像识别
  • ¥15 根据背景及设计要求撰写设计报告
  • ¥20 能提供一下思路或者代码吗
  • ¥15 用twincat控制!
  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1