problems with Printing html: wxHtmlDCRenderer::Render()

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.
Post Reply
Tom82
Experienced Solver
Experienced Solver
Posts: 58
Joined: Wed May 11, 2005 7:45 am

problems with Printing html: wxHtmlDCRenderer::Render()

Post by Tom82 » Tue May 24, 2005 12:56 pm

hi there

i have got a big problem with the HTML Classes.

all what i need is a printout that supports more than 1 html documents, each document printed on its own page.

i am now making a new Printout class,
witch takes for every page printed another html source file, and print down on this page.

i tried many ways, so here is the actual code snipped:

dc is the device context of this page
GenerateAuditHtml is a function that gives the html String back

the idea behind that is that the renderer should render the result of the HTML to the actual device context

the result: Drawing with DC is no problem.
i painted the whole sheet pink so i see every change.
the renderer actually does nothing.

i am using 2.4.2.

[syntax="wxwidgets"]
int height, width ;
dc->GetSize( &width, &height );
wxLogMessage(wxT("Got size of this DC: \nw:%d h:%d"), width, height);



wxPen Pen( wxColour(255,255,255),1,wxSOLID );
dc->SetPen(Pen );

wxBrush brush( wxColour(255, 540, 230 ),wxSOLID);
dc->SetBrush(brush);


dc->DrawRectangle( 0,0,width,height );

wxLogMessage(wxT("Processing printing page: %d"), i);
MeterRead_t* pShiftData = (*it);

wxLogMessage(wxT("generating html..."));
wxString htmlText = GenerateAuditHtmlString(*pShiftData);
wxLogMessage(wxT("finished generating html file...."));

wxLogMessage(wxT("Create new HTML Printout"));
wxHtmlPrintout* phtmlPage = new wxHtmlPrintout( wxT("Audit Data") );

wxLogMessage(wxT("Consturcting Renderer"));
wxHtmlDCRenderer htmlDcRenderer;

wxLogMessage(wxT("Setting HTML Text: %s"), htmlText.c_str() );
htmlDcRenderer.SetHtmlText( htmlText );



wxLogMessage(wxT("Setting Size to X:%d Y:%d..."), width, height );
htmlDcRenderer.SetSize( width, height );


wxLogMessage(wxT("Total Height of the html document: %d"), htmlDcRenderer.GetTotalHeight() );


wxLogMessage(wxT("Setting DC of HTML Renderer to This"));
htmlDcRenderer.SetDC(dc );


wxLogMessage(wxT("Rendering..."));
htmlDcRenderer.Render(0,0);


[/syntax]

AkiraDev
Knows some wx things
Knows some wx things
Posts: 48
Joined: Tue May 24, 2005 9:13 am

Post by AkiraDev » Tue May 24, 2005 1:15 pm

Does calling SetDC() before the other 2 methods help?
Back, just not as often

Windows Vista SP1, Ubuntu 8.04
MinGW 3.4.5, GCC 4.2.1
Code::Blocks
wxWidgets 2.8.9

Tom82
Experienced Solver
Experienced Solver
Posts: 58
Joined: Wed May 11, 2005 7:45 am

Post by Tom82 » Tue May 24, 2005 1:34 pm

WOOOT Thats it,
just put that into the correct order, now this step works.

spent hours in this befor and didnt find anything.

thanks you very much :)

Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg » Tue May 24, 2005 2:45 pm

We missed your presence AkiraDev :-) See people always come back. Now Ryan is here again, and you are too ;-)

Regards,
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb

Post Reply