Recent

Author Topic: Printing in cocoa with Lazarus 2.0  (Read 2331 times)

philgeorges

  • Newbie
  • Posts: 1
Printing in cocoa with Lazarus 2.0
« on: April 12, 2019, 11:38:45 am »
I can't using the printer. Functions works nice in windows, but not in Mojave (cocoa).

Example :

Code: Pascal  [Select][+][-]
  1.   if DlgPrint.Execute then
  2.   begin
  3.     LPrinter := Printer;
  4.     LPrinter.Copies := DlgPrint.Copies;
  5.     try
  6.  
  7.       LBitMap := TBitMap.Create;
  8.       nw := LPrinter.PaperSize.Width;
  9.       nh := LPrinter.PaperSize.Height;
  10.       KeepAspectRatio(pnlResultat.Width,pnlResultat.Height,nw,nh);
  11.       LBitMap.Width := pnlResultat.Width;
  12.       LBitMap.Height := pnlResultat.Height;
  13.  
  14.       LBitMap.Canvas.Brush.Color := clWhite;
  15.       LBitMap.Canvas.Pen.Color :=ClWhite;
  16.       LBitMap.Canvas.Pen.Width:=2;
  17.       LBitMap.Canvas.Rectangle(0, 0,  LBitMap.Width,  LBitMap.Height);
  18.       LBitMap.Canvas.Pen.Color :=ClWhite;
  19.  
  20.       pnlResultat.Color:= clWhite;
  21.       pnlResultat.PaintTo(LBitMap.Canvas, 0, 0);
  22.       LbitMap.Canvas.draw(0,0,Pnlresultat.Canvas);
  23.       Lbitmap.savetofile(extractfilepath(application.exename)+'georges.bmp');
  24.       pnlResultat.Color:= clDefault;
  25.  
  26.       LPrinter.BeginDoc;
  27.      // LPrinter.Title := 'Un titre';
  28.  
  29.       LPrinter.Canvas.CopyRect(Classes.Rect(0, 480, nw, 480+nh),
  30.                LBitMap.Canvas, Classes.Rect(0, 0, LBitMap.Width, LBitMap.Height));
  31.  
  32.     finally
  33.       LPrinter.EndDoc;
  34.       LBitMap.Free;
  35.     end;
  36.   end;
  37. end;

The BMP image is empty, but only in Cocoa, not in windows ! Print preview is empty in cocoa....

A solution ?

Thank you

dbannon

  • Hero Member
  • *****
  • Posts: 2778
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Printing in cocoa with Lazarus 2.0
« Reply #1 on: April 12, 2019, 12:47:27 pm »
http://wiki.lazarus.freepascal.org/Roadmap

Sadly, it indicates that Printing on Cocoa is "not implemented"

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

BeanzMaster

  • Sr. Member
  • ****
  • Posts: 268
Re: Printing in cocoa with Lazarus 2.0
« Reply #2 on: April 12, 2019, 03:25:22 pm »
Hi, Ok printing is not implemented yet but

Copyrect and PaintTo functions not working, the "LBitmap" stay empty with cocoa in all case  %)

apeoperaio

  • Sr. Member
  • ****
  • Posts: 272
Re: Printing in cocoa with Lazarus 2.0
« Reply #3 on: September 20, 2019, 04:06:46 pm »

 

TinyPortal © 2005-2018