質問

I found information about wxHtmlEasyPrinting & other printing features in wxWidgets, however I didn't find something as simple as I actually needed. All I want to do is print a text file

I don't want special formatting, I want a basic printout of basic text file containing say 10 lines of text.

I have a dialog. In this dialog I have a 'print' button. The print button should take you to a print setup page, from where one can get a print out of a text file. (So the print wouldn't be actually printing the dialogue, I dont necessarily need that)

Just to make it easier to understand:

void manual::OnButton1Click(wxCommandEvent& event) 
{
     PrintDialog1->ShowModal();
}

Right now the above code simply shows a print setup page, but obviously, clicking on print gets you nowhere.

Any idea where to start?

役に立ちましたか?

解決

Printing even a plain text file is not that simple, you still need to wrap its lines, paginate it and so on, so you do need your own wxPrintOut implementation. You can look at the printing sample included with wxWidgets to see how to do it. Or you can indeed use wxHtmlEasyPrinting after trivial conversion of the text to HTML (basically you just need to escape the special XML entities).

Another solution is to use an external program for printing, which is the absolutely simplest way to do it, but doesn't provide any UI for the user at all.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top