wxHtmlEasyPrinting problems

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
Timur
In need of some credit
In need of some credit
Posts: 1
Joined: Tue Nov 23, 2004 4:20 pm

wxHtmlEasyPrinting problems

Post by Timur »

hi all,

I need some help from experiensed users of wxWindows library.

I'm developping dll, where one of the functions must provides simple html printing. And wxWindows looks like the best way to get it.

Realization appears to be simple. One must create wxHtmlEasyPrinting class object and use its PrintFile method to make all job. Unfortunetly this object refuses to be cunstructed outside wxFrame class (as it is in "htmlprinting" sample).

Thus, I wrote

Code: Select all

int _tmain(int argc, _TCHAR* argv[])
{
   wxHtmlEasyPrinting *m_Prn;
   m_Prn = new wxHtmlEasyPrinting(_("Easy Printing Demo"), NULL);
   m_Prn -> SetHeader(wxT(""), wxPAGE_ALL);
   m_Prn -> PrintFile("test.html");

   return 0;
}
And have an exception:

assert "(wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL)" failed: wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.

But I do not need any frames or any visual elements to be displayed. I just need to print html transparently.

Thanks in advance.

Best regards,
Khusainov Timur
User avatar
ABX
Can't get richer than this
Can't get richer than this
Posts: 810
Joined: Mon Sep 06, 2004 1:43 pm
Location: Poznan, Poland
Contact:

Re: wxHtmlEasyPrinting problems

Post by ABX »

Timur wrote:I need some help from experiensed users of wxWindows library.
Please, select your favourite way of asking, not all ways of asking. Do not send a question both in forum and wx-users mailing list. Both are visited by experienced developers while it is wasting of their time if two persons answers simultanously in both places. Thanks in advance.

As for your question I do not think you can use wxHtmlEasyPrinting directly from main without all the data it uses internally which can be initialized during wxApp launching. Try do start from modyfing delivered samples to achieve what you want.

ABX
tone.garot
Earned a small fee
Earned a small fee
Posts: 13
Joined: Thu Dec 11, 2014 4:53 pm

Re: wxHtmlEasyPrinting problems

Post by tone.garot »

Hello,

I get the same message described above.

I'm writing unit tests using CppUnit with a console main() instead of a GUI. Fairly straightforward.

When I try to create a unit test for my PrintController class, the message as described above.

The line ( in my PrintController ) in which the message appears:

m_pageSetupData = new wxPageSetupDialogData;

I did a bit of tracing through the stack, and from what I can see, the printing routines on the GUI side of things is handled by wxPrintPaperModule, which is called from wxModule.

Now, on my CppUnit console app, I do create a test wxFrame, and I do initialize a MainApp, but neither wxPrintPaperModule or wxModule occur.

While I would like to write unit tests for completeness (and because unit tests are just the right thing to do), I won't if it doesn't make sense.
Can anyone tell me if there is a way to initialize the underlying printing routines that the GUI side just does all by itself in a console app?

Thanks!
User avatar
xaviou
Super wx Problem Solver
Super wx Problem Solver
Posts: 437
Joined: Mon Aug 21, 2006 3:18 pm
Location: Annecy - France
Contact:

Re: wxHtmlEasyPrinting problems

Post by xaviou »

Hi.
Timur wrote:

Code: Select all

int _tmain(int argc, _TCHAR* argv[])
{
   wxHtmlEasyPrinting *m_Prn;
   m_Prn = new wxHtmlEasyPrinting(_("Easy Printing Demo"), NULL);
   m_Prn -> SetHeader(wxT(""), wxPAGE_ALL);
   m_Prn -> PrintFile("test.html");

   return 0;
}
You can't use wxWidgets like this.
The framework needs a little initialization stuff before.

If you don't want to use a wxApp derived class, have a look at the "console" sample to see how to initialize the libs.

Regards
Xav'
My wxWidgets stuff web page : X@v's wxStuff
tone.garot
Earned a small fee
Earned a small fee
Posts: 13
Joined: Thu Dec 11, 2014 4:53 pm

Re: wxHtmlEasyPrinting problems

Post by tone.garot »

Thanks for the reply.

Directing me to the console app did the trick.

I added the following line.

Code: Select all

wxInitializer initializer;
My unit test runs.
Post Reply