Examples Delphi

TO GET VARIOUS PRINTER SETTINGS:
uses Printers;
type
TOffset = record
X: Integer;
Y: Integer;
end;
[and in the module's class declaration...]
private
{private declarations}
{for printer name...}
prnName: String;
{for printer page height and page width...}
prnPageHeightPixel, prnPageWidthPixel: Integer ;
{for printer page orientation...}
prnOrientation: TPrinterOrientation;
prnPrintOffsetPixels: TOffset;
prnPixelsPerMMX, prnPixelsPerMMY: Real;
prnPageHeightMM: Integer;
public
end;
procedure TEditorForm.GetDeviceSettings;
var
pixelsX, pixelsY: Integer;
begin
{get the name of the default printer...}
prnName := Printer.Printers[Printer.PrinterIndex];
{get the printer page height...}
prnPageHeightPixel := Printer.PageHeight;
{get the printer page width...}
prnPageWidthPixel := Printer.PageWidth;
prnOrientation := Printer.Orientation;
{get the printer page orientation...}
{get the printable area offsets...}
prnPrintOffsetPixels.X := GetDeviceCaps(Printer.Handle, PHYSICALOFFSETX);
prnPrintOffsetPixels.Y := GetDeviceCaps(Printer.Handle, PHYSICALOFFSETY);
{get the pixel to INCH ratio in both X and Y directions...}
pixelsX := GetDeviceCaps(Printer.Handle, LOGPIXELSX);
pixelsY := GetDeviceCaps(Printer.Handle, LOGPIXELSY);
prnPixelsPerMMX := inchesPerMillimeter * pixelsX;
prnPixelsPerMMY := inchesPerMillimeter * pixelsY;
prnPageHeightMM := Round(prnPageHeightPixel/prnPixelsPerMMY);
end;
So, when executing the procedure,
EXAMPLE VALUES OF SOME OF THE VARIABLES ABOVE MIGHT BE:
(where the printer is Epson EPL-5500W and the paper is A4)
prnName = Epson EPL-5500W on LPT1
prnPageHeightPixel = 6799
prnPageWidthPixel = 4799
prnOrientation = poPortrait
prnPrintOffsetPixels.X = 144
prnPrintOffsetPixels.Y = 120
pixelsX = 600
pixelsY = 600
prnPixelsPerMMX = 24
prnPixelsPerMMY = 24
prnPageHeightMM = 283