...die Papiergrösse in Millimeter herausfinden?

Autor: Simon Grossenbacher
Homepage: http://www.swissdelphicenter.ch

Kategorie: Drucken

uses
  
printers;

procedure TForm1.Button1Click(Sender: TObject);
var
  
papermmx, papermmy: Extended;
begin
  
Printer.BeginDoc;

  {
  PHYSICALWIDTH = Dots horizontal of the paper
  LOGPIXELSX    = DPI (Dots per Inch)
  25.4          = To calculte Inch to Millimeter
  }
  
papermmx := GetDeviceCaps(Printer.Canvas.Handle, PHYSICALWIDTH) /
    GetDeviceCaps(Printer.Canvas.Handle, LOGPIXELSX) * 25.4;
  papermmy := GetDeviceCaps(Printer.Canvas.Handle, PHYSICALHEIGHT) /
    GetDeviceCaps(Printer.Canvas.Handle, LOGPIXELSY) * 25.4;

  with Printer.Canvas do
  begin
    
TextOut(200, 100, floattostr(papermmx) + ' mm x ' + floattostr(papermmy) + ' mm');
  end;
  Printer.EndDoc;
end;

 

printed from
www.swissdelphicenter.ch
developers knowledge base