Jump to content
PeterPanettone

Skia Print Preview and Print in Delphi 12?

Recommended Posts

Perusing the source code, it appears that a Print capability is supported.
Regular FMX doesn't have print preview, so I doubt there is SKIA support for that.

 

Share this post


Link to post
2 minutes ago, Lars Fosdal said:

Perusing the source code, it appears that a Print capability is supported.
Regular FMX doesn't have print preview, so I doubt there is SKIA support for that.

 

I need it for a VCL project where I use a TSkSVG component, which I need to PrintPreview and Print.

Share this post


Link to post

You can print to PDF and then show this to the user. I can't tell you how to do this from the top of my head though.

Share this post


Link to post
1 hour ago, Keesver said:

You can print to PDF and then show this to the user. I can't tell you how to do this from the top of my head though.

Yes, please tell me how to do this. Thank you!

Edited by PeterPanettone

Share this post


Link to post
procedure TFMXPrintForm.btnMakePDFClick(Sender: TObject);
var
  r: TRect;
  LCanvas: ISkCanvas;
  LDocument: ISkDocument;
  LDocumentStream: TStream;
  LSVGDOM: ISkSVGDOM;
  LSize: TSizeF;

begin
  LSVGDOM := TSkSVGDOM.MakeFromFile('Delphi.svg');
  LSize := TSizeF.Create(300, 300);
  r.Left := 0;
  r.Top := 0;
  r.Width := Round(treeControl.Width);
  r.Height := Round(treeControl.Height);
  LSVGDOM.SetContainerSize(LSize);

  LDocumentStream := TFileStream.Create('Delphi.pdf', fmCreate);
  try
    LDocument := TSkDocument.MakePDF(LDocumentStream);
    try
      LCanvas := LDocument.BeginPage(r.Width, r.Height);
      try
        LSVGDOM.Render(LCanvas);
      finally
        LDocument.EndPage;
      end;
    finally
      LDocument.Close;
    end;
  finally
    LDocumentStream.Free;
  end;
end;

Also see: Using Skia's PDF Backend | Skia

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×