有没有比 HTML 更好的布局语言用于打印? [英] Is there a better layout language than HTML for printing?

查看:46
本文介绍了有没有比 HTML 更好的布局语言用于打印?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Python 和 Qt 4.4,我必须打印一些页面.最初我想我会使用带有 CSS 的 HTML 来生成这些页面.但是 HTML 有一些限制.

I'm using Python and Qt 4.4 and I have to print some pages. Initially I thought I'd use HTML with CSS to produce those pages. But HTML has some limitations.

现在的问题是:有没有比 HTML 更好但又(或几乎)同样易于使用的东西?此外,它应该与 GPL 兼容.

Now the question is: is there anything that's better than HTML but just (or almost) as easy to use? Additionally, it should be GPL-compatible.

kdgregory &Mark G: 最明显的限制是我无法指定打印机边距.还有一个问题:如何添加页码?

kdgregory & Mark G: The most obvious limitation is that I can't specify the printer margins. There is another problem: How do I add page numbers?

Jeremy French:我必须打印的一件事是某人订购的所有产品的清单,可以分布在几页上.

Jeremy French: One thing I have to print is a list of all the products someone ordered which can spread over a few pages.

推荐答案

8 年来,我一直在与 Python 的打印(或 PDF)输出作斗争,到目前为止,我遇到了以下方法(按个人喜好排序):

I have been fighting with printed (or PDF) output from Python for 8 years now and so far I came across the following approaches (in order of personal preference):

  • 使用 pyJasper(由我编写)或 JasperServer.您可以使用 WYSIWYG 设计工具 iReport 来定义您的布局.您的 Python 代码将通过 HTTP 联系基于 Java 的 Jasper 引擎,并使其呈现 PDF(pyJasper 处理).我们每天使用它来处理几千页.
  • 使用纯文本输出.你不能再快了.我们每天使用它来处理几百页.
  • 使用 XSLT-FO.您还必须调用基于 Java 的渲染引擎,如 FOB.可能会导致性能问题,但可以通过长时间运行的 Java 服务器进程来缓解 - 与 Jasper 的方法相同.我们每天用它写几百页,但是编写 XSLT-FO 文档让我很头疼.不用于新代码.
  • 生成LaTeX 源代码并使用 Latex 软件包渲染为 PDF.让 LaTeX 看起来像是相当困难的.但是只要您使用提供的 LaTeX 样式,就可以了.未用于我店的生产.
  • 使用 ReportLab Toolkit 生成 PDF.水平有点低.更底层:FPDF.我们每天使用 FPDF-Ruby 处理几百页.费了不少功夫才得到我们想要的布局.
  • 直接生成Postscript.奇怪,但在速度和控制方面你几乎无法获得更多.我们用它来生成每天有几十万 Jpeg 的联系表.需要摆弄,但很有趣.
  • 使用 troff/groff 生成 Postscript/PDF.非常低级但很高兴做简单的、高容量的事情.从未在生产中使用它.
  • Using JasperReports via pyJasper (written by me) or JasperServer. You can use the WYSIWYG design tool iReport to define your layout. Your Python code will contact the Java based Jasper engine via HTTP and make it render a PDF (pyJasper handles that). We use that for a few thousand pages a day.
  • Use plain text output. You can't get any faster. We use that for a few hundred pages per day.
  • Use XSLT-FO. You also have to call a Java based rendering engine like FOB. Might result in performance issues but can be mitigated by having a long running Java server process - same approach than with Jasper. We use that for a few hundred pages per day but writing XSLT-FO documents made my head hurt. Not used for new code.
  • Generate LaTeX source and use a latex software package to render to PDF. Getting LaTeX to look like you like is quite difficult. But as long as you go with the provided LaTeX styles, you are fine. Not used in production at my shop.
  • PDF generation with the ReportLab Toolkit. Somewhat low level. Even more low level: FPDF. We use FPDF-Ruby for a few hundred pages a day. Took a lot of fiddeling to get the layout we wanted.
  • Directly generate Postscript. Strange but you nearly can't get more in terms of speed and control. We used that to generate contact sheets with a few hundred thousand Jpegs per day. Takes fiddling but is fun.
  • use troff/groff to generate Postscript/PDF. Very low level bute nice to do simple, high volume things. Never used it thus in production.

对于订单、发票等,我强烈推荐 JasperReports.使用可视化编辑器定义布局的能力可以节省大量时间.

For orders, invoices and the like I highly recommend JasperReports. The ability to use a visual editor to define the layout is a huge time saver.

这篇关于有没有比 HTML 更好的布局语言用于打印?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆