我正嘗試創建一個windows phone 8.1應用程序,用戶可以從鏈接打開pdf文件。假設我想在按下按鈕的情況下從我的應用程序內的下面的鏈接中打開這個pdf文件,而無需在本地下載文件。Windows Phone 8.1 PDF查看器
http://www.analysis.im/uploads/seminar/pdf-sample.pdf
可以這樣用的WebView呢?這個想法是,用戶將通過在線存儲的pdf文件列表並選擇一個本地保存。
我正嘗試創建一個windows phone 8.1應用程序,用戶可以從鏈接打開pdf文件。假設我想在按下按鈕的情況下從我的應用程序內的下面的鏈接中打開這個pdf文件,而無需在本地下載文件。Windows Phone 8.1 PDF查看器
http://www.analysis.im/uploads/seminar/pdf-sample.pdf
可以這樣用的WebView呢?這個想法是,用戶將通過在線存儲的pdf文件列表並選擇一個本地保存。
Windows phone 8.1 webview不支持原生pdf渲染。 你可以看看Mozill pdfJS。希望能幫助到你。
我不確定關於WebView,但是您可以在應用程序中原生呈現PDF。
您可以創建一個流式文件,並將該文件提供給Windows.Data.PDF提供的PDF渲染器。它工作得很好。檢查我的帖子here進行了詳細的教程
public PdfDocument Document { get; set; }
public PdfPage CurrentPage { get; set; }
創建流文件 -
try
{
IRandomAccessStreamReference thumbnail = RandomAccessStreamReference.CreateFromUri(new Uri(webURL));
StorageFile file1 = await StorageFile.CreateStreamedFileFromUriAsync("temp.pdf", new Uri(webURL), thumbnail);
this.Document = await PdfDocument.LoadFromFileAsync(file1)
}
catch (Exception ex)
{
MessageDialog dialog = new MessageDialog(ex.Message);
dialog.ShowAsync();
return;
}
for (int i = 0; i < Document.PageCount; i++)
{
await this.RenderPage(i);
}
渲染網頁 - WP8下
private async Task RenderPage(int index)
{
this.CurrentPage = this.Document.GetPage((uint)index);
using (IRandomAccessStream stream = new MemoryStream().AsRandomAccessStream())
{
await this.CurrentPage.RenderToStreamAsync(stream);
BitmapImage source = new BitmapImage();
source.SetSource(stream);
Image i = new Image();
i.Source = source;
i.Margin = new Thickness(0,5,0,0);
PagePanel.Children.Add(i);
}
}
'Windows.Data.Pdf'命名空間不可用。 1 – zepar 2016-02-18 15:12:26