Scalabium Software |
|
Knowledge for your independence'. | |
Home Delphi and C++Builder tips |
#17: How can I read a printer settings - page sizes and margins? |
|
From today I shall post a some useful functions for printer settings detect. Today I include a functions for printer page width/height and margins getting. function GetPageWidth: Integer; begin Result := GetDeviceCaps(Printer.Handle, PHYSICALWIDTH) end; function GetPageHeight: Integer; begin Result := GetDeviceCaps(Printer.Handle, PHYSICALHEIGHT) end; function GetPageOffsetLeft: Integer; begin Result := GetDeviceCaps(Printer.Handle, PHYSICALOFFSETX) end; function GetPageOffsetRight: Integer; begin Result := GetPageWidth - GetPageOffsetLeft - GetDeviceCaps(Printer.Handle, HORZRES) end; function GetPageOffsetTop: Integer; begin Result := GetDeviceCaps(Printer.Handle, PHYSICALOFFSETY) end; function GetPageOffsetBottom: Integer; begin Result := GetPageHeight - GetPageOffsetTop - GetDeviceCaps(Printer.Handle, VERTRES) end; function GetPixelsPerInchX: Integer; begin Result := GetDeviceCaps(Printer.Handle, LOGPIXELSX) end; function GetPixelsPerInchY: Integer; begin Result := GetDeviceCaps(Printer.Handle, LOGPIXELSY) end; PS: of course, the GetPage* and GetPageOffset* results will be in printer units. If you want to convert in screen units you must calculate: Result := Screen.PixelsPerInch*GetPage.. div GetPixelsPerInchX (or Y)
|
Copyright© 1998-2024, Scalabium
Software. All rights reserved. |