开发者

OS independent printing with Python

I am developing an application which has to be able to print a couple of pages with Python. Now I am searching for a method to create these pages and print them. It should work on Linux and Windows. The pages contain tables, images and text.

I developed the GUI with PyGtk, but I think it's convenient to create an image or开发者_StackOverflow中文版 PDF and print it. I have no idea how to do this. Anyone knows a good way for this?

Note: The problem isn't the generation. It is the printing of that file.


GTK+ has its own printing system, but if you're looking for something Python specific, check out Reportlab.

Printing on Linux is pretty easy with CUPS (just use lp). On Windows, there's no native PDF support though you could print the generated file using the Adobe Reader ActiveX control (here's an example of doing it from .NET). Apparently ShellExecute also works here to tell Adobe Reader to print though I'm not sure how automated it is (i.e. whether you get a dialog box you don't want).


ReportLab is probably what you're looking for.

You may also want to try XHTML2PDF. It's very easy to use. Create your XHTML template. Use Jinja2 (or similar) to fill in the template. Convert to PDF.


Have you considered generating HTML?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜