Printing forms and labels in Python

Diez B. Roggisch deets at nospam.web.de
Sun Jun 13 13:23:46 EDT 2010


Monte Milanuk <memilanuk at gmail.com> wrote:
> On 6/13/10 8:00 AM, Joel Goldstick wrote:
> 
> > Why not go the other direction. Use python to do your processing,
> > and
> > send the results to excel. There are python modules that read and
> > write
> > excel files.
> 
> Well... partly because Excel is not exactly cross-platform.  Granted,
> the mass majority of people using a program like I have in mind will
> be doing so on Windows, but I was hoping to *not* tie things to any
> one platform if I could avoid it.  Probably an overly ambitious goal
> at this point.
> 
> The other part... maybe its my relative newbie experience level
> showing here, but having to call/open Excel to print something from a
> python app feels a little like admitting that python can't do it in a
> reasonable manner.  If I wanted to have to open Excel to print out the
> results, I think I'd just as soon spend the effort and make the whole
> thing an Excel/VBA app and skip python entirely.
> 
> Perhaps (probably) I'm not understanding some of how the lower level
> systems stuff works here...  I thought the print drivers were there to
> take care of the low-level device-specific communication, and provide
> a somewhat simplified common interface for regular programs like M$
> Word, Open Office, Adobe Reader, etc. to use.  Those programs don't
> access the hardware directly, do they?  Don't they hand off the print
> job to the OS-specific print drivers, and let them handle the
> spooling, etc.?  From my (admittedly limited) understanding of things
> on Windows, Mac & Linux, that seems to be somewhat common between
> platforms. Isn't there some sort of module in Python to do the same? 
> I could understand it needing to be somewhat *platform* specific,
> perhaps... but I have old copies of M$ Office 2003 printing out just
> duckily on printers that only came out on the market less than a year
> ago.  I updated the printer drivers and changed the default printer,
> but nothing printer-related in Word or Excel changed (that I know
> of)... but it still manages to hand off to the operating system print
> drivers just fine... which is kind of what I figured Python would do.
> 
> Is that (to some degree) what ReportLab does?

No. Reportlab "just" generates PDF files which your operating system
will print. If you know how to - there used to be times when you just
needed to copy a file to a printer device to print it. 

However, the overall problem here is that printer APIs are very
different between os and they aren't abstracted in python to some common
module. They need access to GUI libraries which python doesn't expose
out of the box. 

So as sad as it may sound - going through some native program such as
excel or acrobat to perform the printing might be your best bet. 

Diez



More information about the Python-list mailing list