Print to file

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
raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 488
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

Print to file

Post by raananb »

How can I store a print image once a page is created using wxPrintout?

(Trunk on Windows 10)
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Print to file

Post by ONEEYEMAN »

Hi,
Why do you want to use wxPrintout?
Can't you just use wxImage->Save()?
Or you are using wxPDF?

Thank you.
raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 488
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

Re: Print to file

Post by raananb »

@Oneeyeman
With wxPrintout I know how to create and print a document, which is what is needed. However, when a document is printed with wxPrintout, there is no trace of it in the system, and I would like to have a copy for archiving. While it is possible to scan the document and save the image, it sound pretty ridiculous as far as applications go.

I have no idea how to transform a wxPrintout to wxImage. It would be useful if you could show the way.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Print to file

Post by ONEEYEMAN »

Hi,
If you are on Windows you can probably print to either PDF or XPS.
I am not sure myself but if you look at the printing sample it can probably show you how to do a different printing.

Thank you.
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Print to file

Post by doublemax »

There is no immediate way to just "grab" the last printed page and store it into a file.

If you have subclassed wxPrintout, you should have a wxPrintout::OnPrintPage(int page) in which you perform the actual drawing. Create a bitmap of the appropriate size and use a wxMemoryDC to draw the same content into the bitmap. Then you can save it as a file.
Use the source, Luke!
Post Reply