2015-02-09 75 views

回答

0

Windows phone 8.1 webview不支持原生pdf渲染。 你可以看看Mozill pdfJS。希望能幫助到你。

-1

我不確定關於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); 
    } 
} 
+2

'Windows.Data.Pdf'命名空間不可用。 1 – zepar 2016-02-18 15:12:26

相關問題