I am trying to link to a pdf in my app resource folder and it opens pdf viewer in simulator mode but when I build it does nothing. Any ideas? Also what’s the status on a webview?
Running on surface 3 pro win 8.1
I am trying to link to a pdf in my app resource folder and it opens pdf viewer in simulator mode but when I build it does nothing. Any ideas? Also what’s the status on a webview?
Running on surface 3 pro win 8.1
I recommend that you display your PDF via system.openURL(). This will open the PDF using the system’s default PDF viewer.
local pdfPath = system.pathForFile("my.pdf", system.ResourceDirectory) system.openURL(pdfPath)
I also recommend that you do the above on Android too, because you can’t depend on the built-in native WebView on Android to support displaying PDFs either.
Awesome! That did it. I was just using system.openURL(“file.pdf”) and not using the pathforfile. Thanks!
Though I would like to open external urls inside the app with a webview option if that’s at all possible I hate that they leave the app to open a browser or pdf viewer. Some users may not be as tech savvy as we’d like them to be
>> I hate that they leave the app to open a browser or pdf viewer.
I think it’s pretty normal for a desktop app. But that said, if we did add native embedded WebView support on Windows, then it would end up using Microsoft’s Internet Explorer, because that’s the only native WebView provided on this platform. By default, it doesn’t support PDFs. You would have to install a PDF viewer ActiveX plugin such as Adobe’s. Although, you could argue that the same is true about system.openURL(), which will return false if there is no app installed to display PDF files… which can definitely happen on Windows 7 and older operating systems (Windows 8 comes with a metro PDF viewer). The difference being is that you have no way of knowing that the WebView failed to display the PDF. So, for the system.openURL() case, you can at least display a message telling the user to install a PDF viewer if it failed to display the file. Anyways, I’m just trying to provide a solution for you that’ll work today. I hope this helps.
I recommend that you display your PDF via system.openURL(). This will open the PDF using the system’s default PDF viewer.
local pdfPath = system.pathForFile("my.pdf", system.ResourceDirectory) system.openURL(pdfPath)
I also recommend that you do the above on Android too, because you can’t depend on the built-in native WebView on Android to support displaying PDFs either.
Awesome! That did it. I was just using system.openURL(“file.pdf”) and not using the pathforfile. Thanks!
Though I would like to open external urls inside the app with a webview option if that’s at all possible I hate that they leave the app to open a browser or pdf viewer. Some users may not be as tech savvy as we’d like them to be
>> I hate that they leave the app to open a browser or pdf viewer.
I think it’s pretty normal for a desktop app. But that said, if we did add native embedded WebView support on Windows, then it would end up using Microsoft’s Internet Explorer, because that’s the only native WebView provided on this platform. By default, it doesn’t support PDFs. You would have to install a PDF viewer ActiveX plugin such as Adobe’s. Although, you could argue that the same is true about system.openURL(), which will return false if there is no app installed to display PDF files… which can definitely happen on Windows 7 and older operating systems (Windows 8 comes with a metro PDF viewer). The difference being is that you have no way of knowing that the WebView failed to display the PDF. So, for the system.openURL() case, you can at least display a message telling the user to install a PDF viewer if it failed to display the file. Anyways, I’m just trying to provide a solution for you that’ll work today. I hope this helps.