【发布时间】:2016-01-08 18:53:20
【问题描述】:
我正在尝试在 Windows Phone 应用程序上使用 Xamarin 打开带有 pdf.js 的 pdf 文件,但无法正常工作。
它正确显示了 pdf.js viewer.html,但我无法打开 pdf 文件。我尝试了以下方法:
PdfWebViewer.Source = "Assets/pdf.js/web/viewer.html?
file=ms-appx:///Assets/Temp/test.pdf";
PdfWebViewer.Source = "Assets/pdf.js/web/viewer.html?
file=Assets/Temp/test.pdf";
PdfWebViewer.Source = "Assets/pdf.js/web/viewer.html?
file=File:///Assets/Temp/test.pdf";
PdfWebViewer.Source = "Assets/pdf.js/web/viewer.html?
file=File://Assets/Temp/test.pdf";
出于测试目的,我的 Assets/Temp 文件夹中有一个 test.pdf 文件,其 ContentType 设置为 Content。
但是上面提到的组合都不起作用。每当我指定文件时,我只会显示“找不到页面”而不是 viewer.html
我需要在 pdf 的底部显示按钮,所以我必须使用我的应用程序打开 pdf。不能使用其他应用打开 pdf。
有什么想法吗?
谢谢。
【问题讨论】:
-
真的有必要使用pdf.js来打开你的PDF吗?我没有使用 pdf.js 在我的应用程序中打开 PDF,所以我无法帮助您。但是我通过启动用户安装的默认 PDF 阅读器应用程序(例如 Acrobat Reader 或 OneReader)从我的应用程序打开 PDF。如果这对您来说是一个可行的选择,请告诉我。
-
我可能应该提到我们不能离开应用程序,因为我们需要在 pdf 的底部显示按钮,但 Xamarin 要求我尝试使用 webview 构建渲染器并调整大小以填充屏幕到我的工具栏。也许这会奏效。我会试一试,如果可行,我会更新这篇文章。
标签: c# windows-phone-8 xamarin windows-phone-8.1 pdf.js