Ive seen a few requests for "print preview" solutions. The problem is, Lazarus doesn't have a TPrinterCanvas which renders to TBitmap's. (There is TPostScriptPrinterCanvas & TCairoPsCanvas)
I started some code a few weeks ago, but, put it on hold because it was messy. ie: Overriding each TCanvas method.
Today, I took another look, and it turns out, you can map a TPrinter to a TBitmap in just over 120 lines of code. Cool.
So, I put together a demo which prints a TRichMemo.
Download from:
http://www.wascal.net/bin/PrintPreview.zipNote: Im using the FreePascal bitmap resamplers, which are slow, so, you may want to use something faster.
I also couldn't find a way to get TRichMemo to print one page. So, my TPrinterBitmap class has the method DoClearPage() which you can use to extract a page before it gets cleared for a new page.
The code should work for any printer enabled controls. Hopefully something similar is added to Lazarus in the future.
Cheers
Derek