I use the Xamarin.Forms 4.6.0.800
I view a PDF file on Android using the following code in the constructor of my ContentPage.
// Get access to the local file system var localFileService = DependencyService.Get<ILocalFileService>(); // Save the PDF to a temporary file var temporaryFile = localFileService.SaveToTempPDFFile(reportName, pdfData); // Set the WebView to reference the temporary PDF file PdfView.Source = $"file:///android_asset/pdfjs/web/viewer.html?file={temporaryFile}"; The XAML is simply:
<ContentPage.Content> <WebView x:Name="PdfView" VerticalOptions="Fill" HorizontalOptions="Fill" /> </ContentPage.Content> This has been working for quite a while, but today on re-testing, I get the following error:
file:///Android_asset/pdfjs/web/viewer.html?file=/data/user/0/com.myApp/cache/reportname.pdf could not be loaded because: net::ERR_FILE_NOT_FOUND Has something changed in Xamarin recently to cause this? In the meantime I am searching for something I may have changed that could be causing this error (as it has been working fine for quite a while now).