preview and print 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.
Post Reply
RobertHK
I live to help wx-kind
I live to help wx-kind
Posts: 158
Joined: Sat Dec 01, 2012 6:43 am

preview and print

Post by RobertHK »

Good day. I would advise. I need to build pages (some pages A4) for preview and printing. On this page you need to place in the frame header (name, city, street, country ....) and then the data from my tables (or classes). It is preferable to proceed in accordance with Chapter 5 (Drawing and Printing) or Chapter 12 (wxHTML)? Thanks for the advice (any advice good).
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: preview and print

Post by doublemax »

If you know some basic HTML and don't need pixel-exact accuracy, wxHtmlEasyPrinting will be much, much easier. The printing framework in wxWidgets is a pain in the ...
Use the source, Luke!
RobertHK
I live to help wx-kind
I live to help wx-kind
Posts: 158
Joined: Sat Dec 01, 2012 6:43 am

Re: preview and print

Post by RobertHK »

Thanks for the quick reply. No, I do not need to know the absolute size of its final document. Only to be printable on A4 (more pages). On these pages I will not make any changes (inputs from the user - not to the tender form). It will be the final print reports such as price lists, budgets. Some data in tables, as some lines (summary), some with frame. So I'm going to study and thanks again.
RobertHK
I live to help wx-kind
I live to help wx-kind
Posts: 158
Joined: Sat Dec 01, 2012 6:43 am

Re: preview and print

Post by RobertHK »

I'm very sorry, but I have a (stupid) question: where do I create a page (paper)? I think the base on which I want to place tables, frames, lines and others? The side that then I print?
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: preview and print

Post by doublemax »

You don't. You just create the html code of the page. Just like in a browser window, the layout will be determined by the size of the paper.
Use the source, Luke!
RobertHK
I live to help wx-kind
I live to help wx-kind
Posts: 158
Joined: Sat Dec 01, 2012 6:43 am

Re: preview and print

Post by RobertHK »

I already know, so sorry. :oops:
RobertHK
I live to help wx-kind
I live to help wx-kind
Posts: 158
Joined: Sat Dec 01, 2012 6:43 am

Re: preview and print

Post by RobertHK »

I know that I'm doing bad, but how can I print a page from wxHtmlWindow? That's what I'm doing (shown here, but bad), only lists everything word for word.

void BaseFrame :: OnPrint (wxCommandEvent & WXUNUSED (event))
{
     m_htmlwin-> SelectAll ();
     m_Prn-> PrintText (m_htmlwin-> SelectionToText ());
}

There is no page layout, as I created it in wxHtmlWindow. I do not load any pages (for example, from a file), I create everything by hand - using: m_htmlwin-> AppendToPage ("...."); Does anyone please advise?
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: preview and print

Post by doublemax »

Code: Select all

m_Prn->PrintText (m_htmlwin->SelectionToText ());
You need to use HTML code here. SelectionToText() only takes the selected text as plain text.

As there is no method to get the current html data from wxHtmlWindow, you have to store it yourself after you created it.
Use the source, Luke!
RobertHK
I live to help wx-kind
I live to help wx-kind
Posts: 158
Joined: Sat Dec 01, 2012 6:43 am

Re: preview and print

Post by RobertHK »

Thanks for the reply. I thought so (and a little worried about that), I'll have to save your data to an HTML file. The problem is that the output file of my application is one database file (for example A1.fdb) - where everything is stored (the entire budget - material and work).
So I'll have to save for one order several files (the first file will be database; 2., 3.,. .. n the html). Then it might make sense to store the result as a multicomponent file with routine *exe. And it I do not know. :(
RobertHK
I live to help wx-kind
I live to help wx-kind
Posts: 158
Joined: Sat Dec 01, 2012 6:43 am

Re: preview and print

Post by RobertHK »

Or even occurred to me to save html pages into the database as a "BLOB" ...
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: preview and print

Post by doublemax »

You don't need to create a html file. Just store everything in a wxString variable. So instead of calling wxHtmlWindow::AppendToPage() multiple times, you add all html code to a wxString variable. If you're done, call wxHtmlWindow::SetPage() once with the complete html code.
Use the source, Luke!
RobertHK
I live to help wx-kind
I live to help wx-kind
Posts: 158
Joined: Sat Dec 01, 2012 6:43 am

Re: preview and print

Post by RobertHK »

This can not be true! It's as simple as that? Thanks very much!
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: preview and print

Post by doublemax »

BTW: I don't know exactly what you're doing, but if you're using the wxHtmlWindow only for a preview, that's not necessary. It's already in wxHtmlEasyPrinting.

Just call wxHtmlEasyPrinting::PreviewText() with the html code. It shows a preview window with zoom and everything.
Use the source, Luke!
RobertHK
I live to help wx-kind
I live to help wx-kind
Posts: 158
Joined: Sat Dec 01, 2012 6:43 am

Re: preview and print

Post by RobertHK »

I'm doing a report for printing. Everything is already filled (north, classes in the program, all variables and other data). Now I need "only" inspect "on paper" and send it to the printer. In wxHtmlWindow there would be no further interference in the code - it is for viewing the report is created.
RobertHK
I live to help wx-kind
I live to help wx-kind
Posts: 158
Joined: Sat Dec 01, 2012 6:43 am

Re: preview and print

Post by RobertHK »

Praised be wxString! Indeed one wxString "swallows" set the whole page code html - including the of tables in the loops and obtaining data from many m_textCtrl. Doblemax, thanks a lot! =D> :D
Post Reply