WxPrintout

From WxWiki

Jump to: navigation, search

[edit] wxWidgets Printing

See also: official docs: wxPrintout

[edit] How to correctly set the device scale to inches

In other frameworks it is common to set the device scale to inches or centimeters and work from there. It would be useful to know how to do this in wxWidgets.

This is how I think you do it:


     // Init the device scale to inches.
     int ppiPrinterX, ppiPrinterY;
     GetPPIPrinter(&ppiPrinterX, &ppiPrinterY);
 
     int pageWidth, pageHeight;
     GetPageSizePixels(&pageWidth, &pageHeight);
 
     int w, h;
     dc->GetSize(&w, &h);
 
     dc->SetUserScale(1.0f/ppiPrinterX * (float)(w/(float)pageWidth), 1.0f/ppiPrinterY * (float)(h/(float)pageHeight));
Personal tools