Jump to content
CarloM

PDF view on Android

Recommended Posts

Hello,

 

I need to show a PDF in app, on iOS works well with TWebBrowser, but no in android.

 

Any workaround, component ?

 

Thank you

  • Thanks 1

Share this post


Link to post

This works for 10.3.x if you have some kind of PDF viewer installed on the device:

uses
  Androidapi.JNI.GraphicsContentViewText, Androidapi.Helpers, Androidapi.JNI.Net;
  
procedure OpenPDF(const AFileName: string);
var
  LIntent: JIntent;
  LUri: Jnet_Uri;
begin
  LUri := TAndroidHelper.JFileToJURI(TJFile.JavaClass.init(StringToJString(AFileName)));
  LIntent := TJIntent.JavaClass.init(TJIntent.JavaClass.ACTION_VIEW);
  LIntent.setDataAndType(LUri, StringToJString('application/pdf'));
  LIntent.setFlags(TJIntent.JavaClass.FLAG_GRANT_READ_URI_PERMISSION);
  TAndroidHelper.Activity.startActivity(LIntent);
end;

 

  • Like 1
  • Thanks 2

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

×