If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
art-ganseforth
Earned some good credits
Posts: 147 Joined: Mon Sep 01, 2014 10:14 am
Post
by art-ganseforth » Wed May 31, 2017 11:03 am
Hi everyone,
i'm trying to find out how to use wxPrintout with wxHtmlDCRenderer. I wrote this simple code for testing, but the result is a white page.
Code: Select all
clsPrint::clsPrint(wxString title) : wxPrintout(title) {}
clsPrint::~clsPrint() {}
bool clsPrint::OnPrintPage (int pageNum) {
wxDC *dc = GetDC();
wxHtmlDCRenderer hdc;
hdc.SetDC (dc);
hdc.SetSize (hdc.GetTotalWidth(),hdc.GetTotalHeight());
hdc.SetHtmlText ("<BODY>this is a test-text</BODY>" );
wxArrayInt pb;
hdc.Render ( 700, 700, pb);
}
By th way: "dc->DrawText()" works.
Has anyone an idea what the problem might be?
Regards,
Frank
doublemax
Moderator
Posts: 19164 Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2
Post
by doublemax » Wed May 31, 2017 2:58 pm
I haven't tested it, but these two lines look suspicious:
Code: Select all
hdc.SetSize (hdc.GetTotalWidth(),hdc.GetTotalHeight());
My guess is that hdc.GetTotalWidth() is still 0 here. Try dc->GetWidth() or hardcoded values for a test.
The parameters give the position, not the dimensions. Shouldn't that be 0,0 ?
Use the source, Luke!
art-ganseforth
Earned some good credits
Posts: 147 Joined: Mon Sep 01, 2014 10:14 am
Post
by art-ganseforth » Wed May 31, 2017 10:22 pm
Seems to work - thank you!
Non-Zero coordinates i used to put the output somehere. In the end i want to print letters with html-fotmated address, body, header and footer. For all of this elements i'll define positioning-rectangles using non-zero-coordinates.
Regards,
Frank