Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > FW: Printing images through Python

Reply
Thread Tools

FW: Printing images through Python

 
 
Tim Golden
Guest
Posts: n/a
 
      10-06-2003
> From: Kevin [mailto(E-Mail Removed)]
> Sent: 04 October 2003 03:21
> To: http://www.velocityreviews.com/forums/(E-Mail Removed)
> Subject: Re: Printing images through Python
>
> Thanks for the help Tim, seems to work well!


Only too glad I could save someone the hours of frustrating
search it took me to get that far.

> One problem I had though, just FYI:
> turned out that printer_resolution[1] was a
> function... have to do more looking to figure out why.


Blowed if I can see why; it's just the return value from GetDeviceCaps.
Ah... looking at my email to you underneath yours to me, the line has
been chopped (hope this makes it across the email systems) thus:

printer_resolution [...] = hDC.GetDeviceCaps [unintended line break]
(VERTRES)

which will make Python think that the second value in
the printer_resolution tuple is the function GetDeviceCaps
and that the (VERTRES) is merely a throwaway value.
It should, of course, read:

[...] = hDC.GetDeviceCaps (VERTRES)

where VERTRES is the parameter to GetDeviceCaps

> I just used [0] for both args and it was fine(for now).


That'll work because, in any case, the code later on takes
the smaller of the two ratios to determine the scaling factor,
and printer_resolution[0] is the width of the page, which
is going to be the smaller of the two anyway.

Hope it works out for you. I haven't yet bothered to go
into using the Printer Setup dialogue, which truly is a
pain. I'm using a Pygame interface, so I'm trying to cut
down on Windows-esque dialog boxes.

TJG

__________________________________________________ ______________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
__________________________________________________ ______________________

 
Reply With Quote
 
 
 
 
Kevin
Guest
Posts: n/a
 
      10-06-2003
Thanks for the follow-up Tim, I caught that error after cleaning my glasses.


I've managed to expand on your example to write a stand-alone module for
handling printing PIL images on Windows. Interfacing to the standard
Windows printer-setup dialog is beyond me for now, so if you have ANY
suggestions I'd appreciate it!

I'm planning on includinga simple GUI class that handles
sizing/margins/etc., but the standard dialogs would be better (and fuller
functionality).

You can try the first "test" version of the module at (and I'd appreciate
some independent testing to make sure it works with many printer setups):

http://www.cazabon.com/python/downloads/WinPILprint.py

However, I'll be releasing a much updated version under a different name in
the next few days (ImagePrintWin, to follow the PIL module naming convention
a little better... hopefully I can convince Fredrik to include the final
version with the standard PIL dist.)

(Thanks again!)

Kevin.

"Tim Golden" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> > From: Kevin [mailto(E-Mail Removed)]
> > Sent: 04 October 2003 03:21
> > To: (E-Mail Removed)
> > Subject: Re: Printing images through Python
> >
> > Thanks for the help Tim, seems to work well!

>
> Only too glad I could save someone the hours of frustrating
> search it took me to get that far.
>
> > One problem I had though, just FYI:
> > turned out that printer_resolution[1] was a
> > function... have to do more looking to figure out why.

>
> Blowed if I can see why; it's just the return value from GetDeviceCaps.
> Ah... looking at my email to you underneath yours to me, the line has
> been chopped (hope this makes it across the email systems) thus:
>
> printer_resolution [...] = hDC.GetDeviceCaps [unintended line break]
> (VERTRES)
>
> which will make Python think that the second value in
> the printer_resolution tuple is the function GetDeviceCaps
> and that the (VERTRES) is merely a throwaway value.
> It should, of course, read:
>
> [...] = hDC.GetDeviceCaps (VERTRES)
>
> where VERTRES is the parameter to GetDeviceCaps
>
> > I just used [0] for both args and it was fine(for now).

>
> That'll work because, in any case, the code later on takes
> the smaller of the two ratios to determine the scaling factor,
> and printer_resolution[0] is the width of the page, which
> is going to be the smaller of the two anyway.
>
> Hope it works out for you. I haven't yet bothered to go
> into using the Printer Setup dialogue, which truly is a
> pain. I'm using a Pygame interface, so I'm trying to cut
> down on Windows-esque dialog boxes.
>
> TJG
>
> __________________________________________________ ______________________
> This e-mail has been scanned for all viruses by Star Internet. The
> service is powered by MessageLabs. For more information on a proactive
> anti-virus service working around the clock, around the globe, visit:
> http://www.star.net.uk
> __________________________________________________ ______________________
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-18-2007 10:11 AM
Printing Images through python post Jody Burgess Python 0 07-16-2004 04:13 PM
RE: Printing images through Python Tim Golden Python 1 10-04-2003 03:17 AM
RE: Printing images through Python Tim Golden Python 0 10-03-2003 08:53 AM
Printing images through Python Kevin Python 0 10-03-2003 05:23 AM



Advertisments