Connecting Tech Pros Worldwide Forums | Help | Site Map

Printing From Python

Fuzzyman
Guest
 
Posts: n/a
#1: Jul 18 '05
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/pyt...er/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

--

http://www.Voidspace.org.uk The Place where headspace meets
cyberspace. Online resource site - covering science, technology,
computing, cyberpunk, psychology, spirituality, fiction and more.

---

http://www.voidspace.org.uk/atlantib...thonutils.html
Pythonutils - home of dateutils, ConfigObj, StandOut etc.....

Thomas Heller
Guest
 
Posts: n/a
#2: Jul 18 '05

re: Printing From Python


michael@foord.net (Fuzzyman) writes:
[color=blue]
> 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/pyt...er/121462.html
> from 2002 giving two different methods for Unix and Windows... the
> windows one doesn't work across our network........[/color]

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
Jamey Cribbs
Guest
 
Posts: n/a
#3: Jul 18 '05

re: Printing From Python


Fuzzyman wrote:
[color=blue]
> Any 'print' modules out there - that implement cross platform printing
> interfaces ?[/color]

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
Harald Massa
Guest
 
Posts: n/a
#4: Jul 18 '05

re: Printing From Python


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

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
Fuzzyman
Guest
 
Posts: n/a
#5: Jul 18 '05

re: Printing From Python


Thomas Heller <theller@python.net> wrote in message news:<7jzahm2e.fsf@python.net>...[color=blue]
> michael@foord.net (Fuzzyman) writes:
>[color=green]
> > 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/pyt...er/121462.html
> > from 2002 giving two different methods for Unix and Windows... the
> > windows one doesn't work across our network........[/color]
>
> 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[/color]


You mean python isn't capable of it ?

Fuzzy
Closed Thread