macos / Linux: App crash when try to print

Issue #244 resolved
Harry Stahl created an issue

Attached you’ll find a printing demo that prints to pages with text (from images), via stretchdraw.

This demo works on window and I used it (similar) also successful with fmxlinux in my program: It would be very helpful if that would work. To have a printing function is important.

procedure TForm41.Button1Click(Sender: TObject);
var
  x: Integer; { ini: TInifile; }
  s: String;
  PaperWRect: TRect;
begin
  with PrintDialog1 do begin
    FromPage := 1;
    ToPage := 2;
    MinPage := 1;
    MaxPage := 2;

    if Execute then begin
      Printer.Title := Caption + '-Ausdruck...';
      PaperWRect :=  Rect (0,0,printer.PageWidth, Printer.PageHeight);

      Printer.BeginDoc;

      If PrintDialog1.PrintRange = prAllPages Then begin
        For x := 1 To MaxPage do begin
          if x = 1 then
            Printer.canvas.StretchDraw(PaperWRect, Image1.picture.bitmap)
          else
            Printer.canvas.StretchDraw(PaperWRect, Image2.picture.bitmap);

          if x < MaxPage then Printer.NewPage;
        end;
      end Else begin
        For x := FromPage To ToPage do begin
          {'Erste Seite evtl. bei Etiketten auf anderem Label anfangen}
          if x = 1 then
            Printer.canvas.StretchDraw(PaperWRect, Image1.picture.bitmap)
          else
            Printer.canvas.StretchDraw(PaperWRect, Image2.picture.bitmap);
          if x < ToPage then Printer.NewPage;
        end;
      End;

      { Drucken ausführen}
      Printer.EndDoc;
    end;
  end;

end;

The printer-dialog shows “Can’t detect file type”. Also it makes no difference selection all or pages, he prints always all.

Under fmxlinux it works so far.

Comments (1)

  1. Log in to comment