【发布时间】:2020-05-31 08:37:31
【问题描述】:
我使用 Xamarin.Forms 4.6.0.800
我在我的 ContentPage 的构造函数中使用以下代码在 Android 上查看 PDF 文件。
// 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}";
XAML 很简单:
<ContentPage.Content>
<WebView
x:Name="PdfView"
VerticalOptions="Fill"
HorizontalOptions="Fill" />
</ContentPage.Content>
这已经工作了一段时间,但是今天重新测试时,我收到以下错误:
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
最近 Xamarin 中是否发生了一些变化导致此问题?与此同时,我正在寻找可能导致此错误的可能已更改的内容(因为它已经运行了很长一段时间了)。
【问题讨论】:
标签: xamarin.forms xamarin.android