Open PDF file in newWebView()

I have project to open PDF file in my Android app.

Using below codes always give me error “Web page not available” ?

[lua]local path = system.pathForFile( “flyer_1.pdf”, system.DocumentsDirectory )
local target = string.gsub(path,“flyer_1.pdf”,"")
print(target)
local webView = native.newWebView( 0, 0, 320, 480, webListener )
webView:request( “flyer_1.pdf” , target )[/lua]

Can someone help to find out how to get real path in Android Device for reading PDF file or other solutions.

Thank you in advanced.

. [import]uid: 100448 topic_id: 32836 reply_id: 332836[/import]

I do this in one of my apps. I found the easiest most consistent way is to load the pdf on a remote server and then use system.OpenURL and open the remote file rather than using the webview. This way the file is downloaded to their downloads directory and they can choose what to open it with… In iOS iBooks comes up as the recommendation to open the remote file.

Matt [import]uid: 18783 topic_id: 32836 reply_id: 130557[/import]

I do this in one of my apps. I found the easiest most consistent way is to load the pdf on a remote server and then use system.OpenURL and open the remote file rather than using the webview. This way the file is downloaded to their downloads directory and they can choose what to open it with… In iOS iBooks comes up as the recommendation to open the remote file.

Matt [import]uid: 18783 topic_id: 32836 reply_id: 130557[/import]

Thank you Matt,

OpenURL only download the file to download folder.

PDF file then need viewer (webView / webPopUp ) but how can I locate the file after download in Android devices?

Regards,

iOS

[import]uid: 100448 topic_id: 32836 reply_id: 130618[/import]

Thank you Matt,

OpenURL only download the file to download folder.

PDF file then need viewer (webView / webPopUp ) but how can I locate the file after download in Android devices?

Regards,

iOS

[import]uid: 100448 topic_id: 32836 reply_id: 130618[/import]

You can’t read a PDF file on Android in a webView or webPopup because it’s not supported. You can use system.openURL to read the PDF if there is another app on the device that’s registered to display PDFs but it will be opened outside of the Corona app.

PDFs can be opened and displayed in iOS webView or webPopup. [import]uid: 7559 topic_id: 32836 reply_id: 131081[/import]

You can’t read a PDF file on Android in a webView or webPopup because it’s not supported. You can use system.openURL to read the PDF if there is another app on the device that’s registered to display PDFs but it will be opened outside of the Corona app.

PDFs can be opened and displayed in iOS webView or webPopup. [import]uid: 7559 topic_id: 32836 reply_id: 131081[/import]

So what if you enabled a web listener with socket library and then connected to that with system.OpenURL(" itms-books://localhost:8080/file.epub ") I tried this and so far it loads ibooks app when I press the button but the book does not load into iBooks…

Any thoughts on that? And to be clear i am not sure my socket is working either. [import]uid: 18783 topic_id: 32836 reply_id: 133501[/import]

Follow up… I can now include the epubs/pdfs inside the bundle and enable a socket listener to listen on a port… using the example above it would open iBooks but not insert the file or anything… just hang… I changed it to the http and it loads safari and prompts to load the file in iBooks much like I did before but the files were remote… this is at least allowing for the files to be local in the bundle now.

Wish I could figure a better way to load the Open in iBooks function or to just load the book…

Matt
[import]uid: 18783 topic_id: 32836 reply_id: 133513[/import]

So what if you enabled a web listener with socket library and then connected to that with system.OpenURL(" itms-books://localhost:8080/file.epub ") I tried this and so far it loads ibooks app when I press the button but the book does not load into iBooks…

Any thoughts on that? And to be clear i am not sure my socket is working either. [import]uid: 18783 topic_id: 32836 reply_id: 133501[/import]

Follow up… I can now include the epubs/pdfs inside the bundle and enable a socket listener to listen on a port… using the example above it would open iBooks but not insert the file or anything… just hang… I changed it to the http and it loads safari and prompts to load the file in iBooks much like I did before but the files were remote… this is at least allowing for the files to be local in the bundle now.

Wish I could figure a better way to load the Open in iBooks function or to just load the book…

Matt
[import]uid: 18783 topic_id: 32836 reply_id: 133513[/import]