Scalabium Software

SMExport advertising
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)


Published: August 20, 1999

See also
 
Database Information Manager
DBISAM Password Recovery
Paradox ActiveX
Paradox Viewer
Excel Reader (dll)
ExcelFile Viewer
ABA Spreadsheet Convert
SMImport suite
ABA Database Convert
SMMsg suite
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2017, Scalabium Software. All rights reserved.
webmaster@scalabium.com

SMExport advertising