Printing From Python

F

Fuzzyman

I looked through the manual, I looked on the web and could find very
little on this subject....

The closest I could find was :
http://www.faqts.com/knowledge_base/view.phtml/aid/4549.

Saying that printing (to a printer :) wasn't easy (at least on
windows - let alone *cross* platform) - and that was dated 2000.

Oh and - http://mail.python.org/pipermail/python-list/2002-September/121462.html
from 2002 giving two different methods for Unix and Windows... the
windows one doesn't work across our network........

Any 'print' modules out there - that implement cross platform printing
interfaces ?

Fuzzy
 
T

Thomas Heller

I looked through the manual, I looked on the web and could find very
little on this subject....

The closest I could find was :
http://www.faqts.com/knowledge_base/view.phtml/aid/4549.

Saying that printing (to a printer :) wasn't easy (at least on
windows - let alone *cross* platform) - and that was dated 2000.

Oh and - http://mail.python.org/pipermail/python-list/2002-September/121462.html
from 2002 giving two different methods for Unix and Windows... the
windows one doesn't work across our network........

Although I am connected to a network printer, I have no problems opening
lpt1:, write some data to it, and the printer prints it:

C:\>net use
Neue Verbindungen werden gespeichert.


Status Lokal Remote Netzwerk

-------------------------------------------------------------------------------
[...]
Getrennt LPT1 \\server\lexmarkps Microsoft Windows-Netzwerk
Der Befehl wurde erfolgreich ausgeführt.


C:\>copy con: lpt1:
hello, world
^Z
1 Datei(en) kopiert.

C:\>


Another thing that comes to mind is something like 'notepad /p x.txt'.

If you want to print other things than simple text files, it gets more
complicated IMO.

Thomas
 
J

Jamey Cribbs

Fuzzyman said:
Any 'print' modules out there - that implement cross platform printing
interfaces ?

Well, this solution isn't cross platform, it isn't written in Python,
and it isn't free, but I have used it quite a bit and it works great (on
Windows, at least).

Rpv (http://www.rpvreport.com) is a report generator that is totally
unlike Crystal Reports or other products. To me, it fills a great niche
between complex, gui-designer report writers like Crystal, and the other
end of the spectrum such as trying to format text as an html document
and then doing an external call to your web browser.

Basically, Rpv is a program that will read a text file that your program
creates that will have all of the data that you want to print. It then
reads a template file (another text file) that you create beforehand,
which tells it how to format the report, where to place the data from
the text file, where the headers go, etc.

So, basically the steps I use in a program to let the user print data are:

1). Create the text file containing the data.
2). Do an external call to Rpv, passing it the name of the text file
and the name of the template file.
3). Rpv then opens up a nice print preview window that shows the user
what the report will look like with all of the data included.
4). The user can then press the print button in the preview window and
print the report.

Combined with pygtk (or wxPython), it makes your application look
professional.

And Rpv is pretty cheap. I think I paid something like $40 for an
royalty free version that lets me use it and distribute the runtime to
all my customers.

Also, I have absolutely no connection to the makers of Rpv, I just
really like their product.

Hope this helps.

Jamey
 
H

Harald Massa

Saying that printing (to a printer :) wasn't easy (at least on
windows - let alone *cross* platform) - and that was dated 2000.

Printing is not easy, it is a complicated matter.

You can find 4 simplifications:

1) wxPython has a print-framework, wxPython is cross platform (alas, I only
used it in win32)

2) print postscript. Ghostscript is available on "every" platform.
(printing on PDAs and watches is really different). Postscript is
documented

3) create PDF. PDF viewers & printers are available on "every" platform.
PDF can be created by (free) ReportLab toolkit, and I'm sure there are more
PDF-Classes

4) create XHTML & a Print.CSS. HTML viewers are available on every
Plattform, .CSS allows fairly good styling of printouts.


Harald
 
F

Fuzzyman

Thomas Heller said:
I looked through the manual, I looked on the web and could find very
little on this subject....

The closest I could find was :
http://www.faqts.com/knowledge_base/view.phtml/aid/4549.

Saying that printing (to a printer :) wasn't easy (at least on
windows - let alone *cross* platform) - and that was dated 2000.

Oh and - http://mail.python.org/pipermail/python-list/2002-September/121462.html
from 2002 giving two different methods for Unix and Windows... the
windows one doesn't work across our network........

Although I am connected to a network printer, I have no problems opening
lpt1:, write some data to it, and the printer prints it:

C:\>net use
Neue Verbindungen werden gespeichert.


Status Lokal Remote Netzwerk

-------------------------------------------------------------------------------
[...]
Getrennt LPT1 \\server\lexmarkps Microsoft Windows-Netzwerk
Der Befehl wurde erfolgreich ausgeführt.


C:\>copy con: lpt1:
hello, world
^Z
1 Datei(en) kopiert.

C:\>


Another thing that comes to mind is something like 'notepad /p x.txt'.

If you want to print other things than simple text files, it gets more
complicated IMO.

Thomas


You mean python isn't capable of it ?

Fuzzy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,173
Latest member
GeraldReund
Top