Jump to content
Jolubaro

Printing from Android Device

Recommended Posts

Hi!!

I'm trying to print an image from my cell with this code, but it is imposible. 'Access Violation'.

 

procedure TFPrincipal.BImprimirClick(Sender: TObject);
var
  SrcRect, DestRect: TRectF;
begin
  with Printer do
    begin
      ActivePrinter.SelectDPI(1200,1200);
      Canvas.Fill.Color:= TAlphaColorRec.Black;
      Canvas.Fill.Kind := TBrushKind.Solid;
      BeginDoc;
      SrcRect := Image.LocalRect;
      DestRect := TRectF.Create(0, 0, PageWidth, PageHeight);
      Canvas.DrawBitmap(Image.Bitmap, SrcRect, DestRect, 1);
      EndDoc
    end
end;

Share this post


Link to post

Thank you. So, with FMX there is not solution for my problem. What about other platforms of programming

Share this post


Link to post
1 hour ago, Jolubaro said:

So, with FMX there is not solution for my problem

There can be solutions; just that there isn't any included with Delphi. This is a potential starting point: https://developer.android.com/training/printing, though you will need knowledge of Java, and how to convert the code to Delphi.

1 hour ago, Jolubaro said:

What about other platforms of programming

If you mean development tools other than Delphi, there could be solutions using those, however it may still require writing the same code as per the link mentioned above, i.e. it would be unlikely to be included with the development tool itself.

Share this post


Link to post

I've never tried to print anything on Android, but on iOS, when sharing a PDF, the "Print" option appears in the system menu. If this happens on Android, it would be a very simple solution to implement. To make the PDF just use Skia4delphi, and to share the PDF, it's very simple, I even have a code ready (if you confirm that this solution works, I'll send it to you).

  • Like 1

Share this post


Link to post

Thanks to both of you. I will take your suggestions into account. I have to think about what I'm going to do finally.

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

×