Current size of printer page?

How do I find out the size of the page for the currently
selected printer? Note that I need the size of the
drawable area, not the size of the paper.

I am doing something similar to creating posters. If
I know how many pages wide the user wants, I need to
calculate how many pages tall it will be.

The drawable area can be changed on many printers through
user options as well.

I would also like to know the aspect ratio of the printer
pixels. For my Epson inkjet they seem to be about 1.003.

Finally the SetUserScale method doesn't work on my printer
for values outside a small range. (I was trying to make
one pixel in my source image be 100 in the printer device
context. The scale numbers I was using were numbers
similar to 1978. They work fine for preview but not
for actual printing, which results in no drawing at
all.)

Roger

Roger Binns wrote:

How do I find out the size of the page for the currently
selected printer? Note that I need the size of the
drawable area, not the size of the paper.

I think you have to have started the printing process in order to
get that info. See the methods of wxPrintout for example. There may be
other ways to get it though, try asking on wx-users.

ยทยทยท

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

Roger Binns wrote:
> How do I find out the size of the page for the currently
> selected printer? Note that I need the size of the
> drawable area, not the size of the paper.

I think you have to have started the printing process in order to
get that info. See the methods of wxPrintout for example. There may be
other ways to get it though, try asking on wx-users.

This code worked for me in the end. wxPython 2.4.2.4 on Windows, Linux
and Mac:

   def GetCurrentPrinterSize(self):
        if hasattr(wx, "PrinterDC"):
            try:
                dc=wx.PrinterDC(self.printdata)
            except:
                if not self.printerwarned:
                    self.printerwarned=True
                    self.WarnAboutNoPrinter()
                return (2976, 3720) # US Letter
        else:
            dc=wx.PostScriptDC(self.printdata)
        pw,ph=dc.GetSizeTuple()
        del dc
        return pw,ph

The documentation implies that I am very naughty for using PrinterDC :slight_smile:

Roger