Re: General questions about ReportLab
"Henning von Bargen" <[email protected]>
| Newsgroups | gmane.comp.python.reportlab.user |
|---|---|
| Message-ID | <[email protected]> |
Regarding PDF printing: > There are times when a user wants to run a report and send it to a printer straight away. > I have read a bit about installing GhostScript, using it to convert PDF to PostScript, > and sending it to a PostScript printer. Is this the recommended solution? For windows, using GhostScript is theoretically possible. We tried this with an early version of our commercial product (http://www.t-p.com/lisalims/), but soon gave up, because for each printer one has to use different command line flags and the overall results were not satisfying, so I don't recommend this. We then switched to the excellent (but commercial!) PDF printing library from http://www.pdf-tools.com. If anyone is interested, we used SWIG to create a Python wrapper for their API. > In order for me to print directly to a printer, I need to know which printers are available. Yes. Or at least, you need to know the destination printer's name in the OS. > Is there a cross-platform way of enquiring from the system which printers are installed? AFAIK: No. > If not I can create a database table to store printer information which the user must fill in manually. > At a minimum I would need printer name and page size. Has anyone done this? We did this for our commercial solution. However, we only store if it's a label printer or not, and if a particular printer tray must be selected. The aforementioned PDF library can auto-rotate the pages and choose a paper size, and it's possible to select a tray (e.g. for A3 printing). > Is there a cross-platform way of actually sending a stream of bytes to the print spooler. > Is 'lpr' the answer? Does it work on Windows? No and No. However, if you create printer code (e.g. ZPL II for Stripe Zebra label printers), it's possible to send these to the printer directly. We are using this to create label directly (without RL or any report engine). Note: This does not work with PDF. > Some users still want to print invoices on multi-part paper on a dot-matrix printer. > Can PDF be used for this at all, or must I come up with some other solution? Theoretically, this should be possible, but I would not recommend that. Due to the low resolution of dot-matrix printers, it's probably better to create something like PCL or whatever directly. > Print previews - I have written the client side of my application in Javascript, so that it will run in any browser. > Is there a way of generating a PDF file from RL and displaying it in the browser, without writing it to a file? Yes. RL can send the output to a stream, but probably it's better to use StringIO or a temporary file (depending on the expected size) because the HTTP header should contain content-length information. HTH Henning