wxPrintout

Hello, I'm new on this list.

I have a problem with wxPrintout class.
I calculate number of printout pages in OnPreparePrinting method. (doc: "Called once by the framework before any other demands are made of the wxPrintout object. This gives the object an opportunity to calculate the number of pages in the document, for example.")
But the method GetPageInfo() is called before OnPreparePrinting(), so print window gets wrong total number of pages.

witek wolejszo

Witek Wo³ejszo wrote:

Hello, I'm new on this list.

I have a problem with wxPrintout class.
I calculate number of printout pages in OnPreparePrinting method. (doc:
"Called once by the framework before any other demands are made of the
wxPrintout object. This gives the object an opportunity to calculate the
number of pages in the document, for example.")
But the method GetPageInfo() is called before OnPreparePrinting(), so
print window gets wrong total number of pages.

I had the same problem. I found no other solution but to calculate the
number of pages in GetPageInfo() method (alternatively you can call some
method, "CalculateNumberOfPages" for example, from the GetPageInfo() method,
that calculates the number of pages and returns it to GetPageInfo() )

Ilia Kats wrote:

Witek Wo³ejszo wrote:

Hello, I'm new on this list.

I have a problem with wxPrintout class.
I calculate number of printout pages in OnPreparePrinting method. (doc:
"Called once by the framework before any other demands are made of the
wxPrintout object. This gives the object an opportunity to calculate the
number of pages in the document, for example.")
But the method GetPageInfo() is called before OnPreparePrinting(), so
print window gets wrong total number of pages.
   

I had the same problem. I found no other solution but to calculate the
number of pages in GetPageInfo() method (alternatively you can call some
method, "CalculateNumberOfPages" for example, from the GetPageInfo() method,
that calculates the number of pages and returns it to GetPageInfo() )

I'll try. The problem is that I cannot retrieve information about page size when GetPageInfo is first called and I cannot check printed text dimensions without dc obejct.

witek

Witek Wo³ejszo wrote:

Ilia Kats wrote:

>Witek Wo³ejszo wrote:
>
>>I have a problem with wxPrintout class.
>>I calculate number of printout pages in OnPreparePrinting method. (doc:
>>"Called once by the framework before any other demands are made of the
>>wxPrintout object. This gives the object an opportunity to calculate the
>>number of pages in the document, for example.")
>>But the method GetPageInfo() is called before OnPreparePrinting(), so
>>print window gets wrong total number of pages.
>>
>>
>I had the same problem. I found no other solution but to calculate the
>number of pages in GetPageInfo() method (alternatively you can call some
>method, "CalculateNumberOfPages" for example, from the GetPageInfo()

method,

>that calculates the number of pages and returns it to GetPageInfo() )
>
>
I'll try. The problem is that I cannot retrieve information about page
size when GetPageInfo is first called and I cannot check printed text
dimensions without dc obejct.

I know. I had this problem too. What I did is the following (changed the
OnBeginPrinting method):

···

#------------------------
def OnBeginPrinting(self):
        maxX = 650 #width of the wanted DC
        maxY = 800 #height of the wanted DC

        self.dc = self.GetDC()

        # Setting scaling factors...
        # Get the size of the DC in pixels
        (w, h) = self.dc.GetSizeTuple()

        # Calculate a suitable scaling factor
        scaleX = float(w) / maxX
        scaleY = float(h) / maxY

        # Use x or y scaling factor, whichever fits on the DC
        actualScale = min(scaleX, scaleY)

        # Set the scale and origin
        self.dc.SetUserScale(actualScale, actualScale)
        self.dc.SetDeviceOrigin(0,0)

        self.base_OnBeginPrinting()

#------------------------

Now, my page size will be maxX*maxY (650*800). Now, whenever I want to draw
on the DC, I am drawing on "self.dc". Try this one. I hope it will help
you.

Ilia Kats wrote:

Thnx. I'll inform You about my results. :slight_smile:

witek