Need help with wxPrintout / wxHtmlDCRenderer Topic is solved

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
Earned some good credits
Posts: 147
Joined: Mon Sep 01, 2014 10:14 am

Need help with wxPrintout / wxHtmlDCRenderer

Post by art-ganseforth »

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
User avatar
doublemax
Moderator
Moderator
Posts: 19164
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Need help with wxPrintout / wxHtmlDCRenderer

Post by doublemax »

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.

Code: Select all

hdc.Render ( 700, 700, pb);
The parameters give the position, not the dimensions. Shouldn't that be 0,0 ?
Use the source, Luke!
art-ganseforth
Earned some good credits
Earned some good credits
Posts: 147
Joined: Mon Sep 01, 2014 10:14 am

Re: Need help with wxPrintout / wxHtmlDCRenderer

Post by art-ganseforth »

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