One of the apps I ported from iOS to Windows 10 using WinObjC was using the web view to open up pdf files that were deployed with the app. While this works fine in iOS it does not port well to Win10 since the Edge browser does not support (yet ?) opening up a PDF file directly.
I’ve thought of a few approaches like use another web browser component - Awesomium or render the PDF yourself using the Windows.Data.PDF classes, but these require extensive changes to your code base which is not something you want in this process.
Depending on the complexity of the PDF or the requirement, you could simply convert the pdf to a HTML file.
The best tool I’ve found to achieve this is pdf2htmlex. The best thing about the tool is that it generates the HTML in one file (embedding the images as Base64 strings) so it’s super easy to just add that file and replace the PDF reference.
Sometimes the conversion will simply not work due to the formatting or layout of the PDF. In this case, the only viable solution is to change the original code to open the PDF in the native PDF reader application rather than in the web view.
Here’s how you would write this code in a regular UWP app:
var fileUri = new Uri("ms-appx:///mypdf.pdf");
But we need to write it all using ObjectiveC so here’s the final code that you can put in your iOS app to achieve the same functionality: