+#if wxUSE_ENH_METAFILE
+bool wxWindowsPrintPreview::RenderPageIntoBitmap(wxBitmap& bmp, int pageNum)
+{
+ // The preview, as implemented in wxPrintPreviewBase (and as used prior to
+ // wx3) is inexact: it uses screen DC, which has much lower resolution and
+ // has other properties different from printer DC, so the preview is not
+ // quite right.
+ //
+ // To make matters worse, if the application depends heavily on
+ // GetTextExtent() or does text layout itself, the output in preview and on
+ // paper can be very different. In particular, wxHtmlEasyPrinting is
+ // affected and the preview can be easily off by several pages.
+ //
+ // To fix this, we render the preview into high-resolution enhanced
+ // metafile with properties identical to the printer DC. This guarantees
+ // metrics correctness while still being fast.
+
+
+ // print the preview into a metafile:
+ wxPrinterDC printerDC(m_printDialogData.GetPrintData());
+ wxEnhMetaFileDC metaDC(printerDC,
+ wxEmptyString,
+ printerDC.GetSize().x, printerDC.GetSize().y);
+
+ if ( !RenderPageIntoDC(metaDC, pageNum) )
+ return false;
+
+ wxEnhMetaFile *metafile = metaDC.Close();
+ if ( !metafile )
+ return false;
+
+ // now render the metafile:
+ wxMemoryDC bmpDC;
+ bmpDC.SelectObject(bmp);
+ bmpDC.Clear();