Hello everyone.
Does anyone here have any experience using wxHtmlPrintout? I am writing
an application that uses a subclass of this class. I subclassed it according
to what was described in the documentation. The required methods have
been overridden in the subclass as follows:
def OnBeginDocument(self, start, end):
return self.base_OnBeginDocument(start, end)
def OnEndDocument(self):
self.base_OnEndDocument()
def OnBeginPrinting(self):
self.base_OnBeginPrinting()
def OnEndPrinting(self):
self.base_OnEndPrinting()
def OnPreparePrinting(self):
self.base_OnPreparePrinting()
def HasPage(self, page):
if page <= self.__page_count:
return True
else:
return False
def GetPageInfo(self):
return (1, self.__page_count, 1, self.__page_count)
def OnPrintPage(self, page):
self.SetHtmlText(self.compose_html_for_page(page))
return wxHtmlPrintout.OnPrintPage(self, page)
I am using wxHtmlPrintout subclass because I need to have it generate
new HTML document each time a page is printed. That is, I can store the
data needed for the pages in an array, one element for each page, each
element containing data that compose_html_for_page() requires for a
given page. The preview window displays, but there is no text. I have it
echo the generated HTML to stdout, no errors in the HTML. I tried
putting "tracers" inside the overridden methods, it seems that they are
not getting called by the print framework. eg, the overridden
OnPrintPage() method in the subclass is not being called. I used the
code in the wxPYthon samples for PrintFramework as the basis for my
own code. But the PrintFramework sample derives directly from
wxPrintout, and not wxHtmlPrintout. I read the docs and it says
wxHtmlPrintout is derived from wxPrintout. I gather if I subclass
wxHtmlPrintout I can create a new class that behaves differently when
OnPrintPage is called. But it seems it does not work that way.
Anyone have any ideas on how to go about deriving from wxHtmlPrintout
"properly"?
Incidentally, I also tried deriving from wxPrintout and used
wxHtmlDCRenderer() to render the HTML on the printout's DC. No such
luck, no HTML text output and Render() returns zero. Plus it does not
work under wxGTK.
Other ideas are also welcome. I just wanted to have a convenient way of
printing out formatted and laid out documents (with possibility of
including graphics), which is why I used wxHtmlPrintout (and the
wxHtmlDCRenderer inside a wxPrintout subclass).
My software versions:
Windoze98 - wxPython 2.4.0.6 under Python 2.2.2
Linux - wxPython 2.4.1.2 under Python 2.2.2
···
--
Public Key here:
http://abingfamily.net/~nimrod/nimrod_at_abingfamily_dot_net.asc
Key expires 2004-06-03