2016-11-09 49 views
0

当我尝试使用Android上的TwebBrowser从URL打开.pdf时,PDF不要打开,只是一个空白的窗口。在Android上使用TwebBrowser从URL加载pdf时出错

TwebBrowser.Navigate('http://url/pdf/{3F6E0442-F389-4A49-8587-E02757340052}.pdf'); 

在win32上工作正常 在Android上不打开pdf。

感谢

+0

'TWebBrowser'是各自原生平台浏览器的包装。原生的win32和iOS浏览器支持直接查看PDF文件,而android本机浏览器则不支持。 –

回答

1

不要使用WebBrowser组件。使用安装的默认应用程序打开这种类型的文件。

uses 
    Androidapi.JNI.GraphicsContentViewText, 
    Androidapi.JNI.JavaTypes, 
    FMX.Helpers.Android; 

procedure OpenFile(pFileName:string); 
var 
    Intent: JIntent; 
begin 
    Intent := TJIntent.Create; 
    Intent.setAction(TJIntent.JavaClass.ACTION_VIEW); 
    Intent.setDataAndType(StrToJURI(pFileName), StringToJString('application/pdf')); 
    SharedActivity.startActivity(Intent); 
end;