Delphi Can
Image Yazdırma - Baskı Önizleme

+- Delphi Can (https://www.delphican.com)
+-- Forum: Delphi (https://www.delphican.com/forumdisplay.php?fid=3)
+--- Forum: Genel Programlama (https://www.delphican.com/forumdisplay.php?fid=6)
+--- Konu Başlığı: Image Yazdırma (/showthread.php?tid=7755)



Image Yazdırma - barissagir - 07-06-2024

Merhabalar

Formdaki Image nesnesini nasıl yazdırabilirim?

Nette bi çok kod var ama hep yazıcıdan boş kağıt çıkıyor.

Örnek
procedure TKomisyonFisiEvrakF.resim_yazdir(Image:TImage);
var
 ScaleX, ScaleY: Integer;
 RR: TRect;
begin
 with Printer do
 begin
   BeginDoc;
   // Mit BeginDoc wird ein Druckauftrag initiiert.
   // The StartDoc function starts a print job.
   try
     ScaleX := GetDeviceCaps(Handle, logPixelsX) div PixelsPerInch;
     ScaleY := GetDeviceCaps(Handle, logPixelsY) div PixelsPerInch;
     // Informationen über die Auflösung
     // Retrieves information about the Pixels per Inch of the Printer.
     RR := Rect(0, 0, Image1.picture.Width * scaleX, Image.Picture.Height * ScaleY);
     Canvas.StretchDraw(RR, Image.Picture.Graphic);
     // An die Auflösung anpassen
     // Stretch to fit

   finally
     EndDoc;   //Methode EndDoc beendet den aktuellen Druckauftrag und schließt die
     // Textdatei-Variable.
     // Steht in finally - um auch bei Abbruch des Druckauftrages Papierausgabe
     // sicherzustellen
   end;
 end;
end;



Cvp: Image Yazdırma - hi_selamlar - 07-06-2024

(07-06-2024, Saat: 18:28)barissagir Adlı Kullanıcıdan Alıntı: Merhabalar

Formdaki Image nesnesini nasıl yazdırabilirim?

Nette bi çok kod var ama hep yazıcıdan boş kağıt çıkıyor.

Örnek
procedure TKomisyonFisiEvrakF.resim_yazdir(Image:TImage);
var
 ScaleX, ScaleY: Integer;
 RR: TRect;
begin
 with Printer do
 begin
   BeginDoc;
   // Mit BeginDoc wird ein Druckauftrag initiiert.
   // The StartDoc function starts a print job.
   try
     ScaleX := GetDeviceCaps(Handle, logPixelsX) div PixelsPerInch;
     ScaleY := GetDeviceCaps(Handle, logPixelsY) div PixelsPerInch;
     // Informationen über die Auflösung
     // Retrieves information about the Pixels per Inch of the Printer.
     RR := Rect(0, 0, Image1.picture.Width * scaleX, Image.Picture.Height * ScaleY);
     Canvas.StretchDraw(RR, Image.Picture.Graphic);
     // An die Auflösung anpassen
     // Stretch to fit

   finally
     EndDoc;   //Methode EndDoc beendet den aktuellen Druckauftrag und schließt die
     // Textdatei-Variable.
     // Steht in finally - um auch bei Abbruch des Druckauftrages Papierausgabe
     // sicherzustellen
   end;
 end;
end;

Merhabalar,

uses
  Printers, Vcl.Graphics;

procedure TForm1.Button1Click(Sender: TObject);
var
 PrintBitmap: TBitmap;
begin
 if PrintDialog1.Execute then
 begin
   Printer.BeginDoc;
   try
     PrintBitmap := TBitmap.Create;
     try
       PrintBitmap.Assign(Image1.Picture.Graphic);
       Printer.Canvas.StretchDraw(Rect(0, 0, Printer.PageWidth, Printer.PageHeight), PrintBitmap);
      finally
       PrintBitmap.Free;
     end;
   finally
     Printer.EndDoc;
   end;
 end;
end;



Cvp: Image Yazdırma - barissagir - 08-06-2024

(07-06-2024, Saat: 19:49)hi_selamlar Adlı Kullanıcıdan Alıntı:
(07-06-2024, Saat: 18:28)barissagir Adlı Kullanıcıdan Alıntı: Merhabalar

Formdaki Image nesnesini nasıl yazdırabilirim?

Nette bi çok kod var ama hep yazıcıdan boş kağıt çıkıyor.

Örnek
procedure TKomisyonFisiEvrakF.resim_yazdir(Image:TImage);
var
 ScaleX, ScaleY: Integer;
 RR: TRect;
begin
 with Printer do
 begin
   BeginDoc;
   // Mit BeginDoc wird ein Druckauftrag initiiert.
   // The StartDoc function starts a print job.
   try
     ScaleX := GetDeviceCaps(Handle, logPixelsX) div PixelsPerInch;
     ScaleY := GetDeviceCaps(Handle, logPixelsY) div PixelsPerInch;
     // Informationen über die Auflösung
     // Retrieves information about the Pixels per Inch of the Printer.
     RR := Rect(0, 0, Image1.picture.Width * scaleX, Image.Picture.Height * ScaleY);
     Canvas.StretchDraw(RR, Image.Picture.Graphic);
     // An die Auflösung anpassen
     // Stretch to fit

   finally
     EndDoc;   //Methode EndDoc beendet den aktuellen Druckauftrag und schließt die
     // Textdatei-Variable.
     // Steht in finally - um auch bei Abbruch des Druckauftrages Papierausgabe
     // sicherzustellen
   end;
 end;
end;

Merhabalar,

uses
  Printers, Vcl.Graphics;

procedure TForm1.Button1Click(Sender: TObject);
var
 PrintBitmap: TBitmap;
begin
 if PrintDialog1.Execute then
 begin
   Printer.BeginDoc;
   try
     PrintBitmap := TBitmap.Create;
     try
       PrintBitmap.Assign(Image1.Picture.Graphic);
       Printer.Canvas.StretchDraw(Rect(0, 0, Printer.PageWidth, Printer.PageHeight), PrintBitmap);
      finally
       PrintBitmap.Free;
     end;
   finally
     Printer.EndDoc;
   end;
 end;
end;

Cevap için çok teşekkür ederim.