Einzelnen Beitrag anzeigen

mmw
(Gast)

n/a Beiträge
 
#10

AW: Bild in TImage auf dem Drucker ausdrucken

  Alt 31. Jul 2021, 15:28
hallo,

wenn die Graphic zuerst gedruckt wird, funkionierts.

Delphi-Quellcode:
var
  ScaleX, ScaleY: Integer;
  RR: TRect;
  map_mode: Integer;
begin
  if PrintDialog1.Execute then
  begin
    //Printer.Title := 'Bild Drucken Delphi';
    Printer.Orientation := poPortrait;
    Printer.BeginDoc;


    map_mode := GetMapMode(Printer.Canvas.Handle);

    Printer.Canvas.Font.Name := 'Arial';
    SetTextAlign(Handle, TA_LEFT + TA_TOP);
    Printer.Canvas.Font.Size := 8;
    Printer.Canvas.TextOut(200, -50, 'Test');

    try

    //SetMapMode(Printer.Canvas.Handle, map_mode);
      ScaleX := GetDeviceCaps(Printer.Handle, LOGPIXELSX) div PixelsPerInch;
      ScaleY := GetDeviceCaps(Printer.Handle, LOGPIXELSY) div PixelsPerInch;
      RR := Rect(0, 0, Image1.picture.Width * ScaleX, Image1.Picture.Height * ScaleY);
      Printer.Canvas.StretchDraw(RR, Image1.Picture.Graphic);

      Printer.Canvas.TextOut(0, 0, '');
      SetMapMode(Printer.Canvas.Handle, MM_LOMETRIC);
      Printer.Canvas.Font.Name := 'Arial';
      SetTextAlign(Handle, TA_LEFT + TA_TOP);
      Printer.Canvas.Font.Size := 8;
      Printer.Canvas.TextOut(200, -50, 'Test');

      Printer.EndDoc;

    except
      Printer.Abort
    end;
  end;

Gruß
  Mit Zitat antworten Zitat