Xamarin Forms UWP - 显示 PDF [英] Xamarin Forms UWP - Display PDF

查看:21
本文介绍了Xamarin Forms UWP - 显示 PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我并告诉我我错过了什么.

我的目标是显示简单的 PDF 文件(例如存储在本地)在 WebView 控件中.我可以将文件的路径绑定到 WebView 的 Source 属性吗?或者在 UWP 中显示 PDF 的正确方法是什么?

附言如果唯一的选择是像

<块引用>

或者在 UWP 中显示 PDF 的正确方法是什么?

在uwp app中,可以使用Image来展示PDF文件,可以参考官方PDF 文档样本.但是我不知道PDF在Android和IOS应用程序中是否可以显示为Image,因为您正在开发一个跨平台项目,我认为最好使用内置方法来解决此类问题.

如果需要xamarin UWP的demo,可以留言,我稍后会上传我的demo.

Please, help me and tell me what am I missing.

My goal is to display simple PDF file (stored locally for example) in the WebView control. Can I bind path of the file to the Source property of the WebView? Or what is the correct way to show PDF in UWP?

P.S. and if the only option is to do like here - how must I add pdf.js to my project??

解决方案

My goal is to display simple PDF file (stored locally for example) in the WebView control.

If you want to display pdf in WebView control, then the methods in Display a Local PDF File in a WebView is most like the only way to solve your problem.

You can follow the steps in the xamarin official document, and here are some additional tips we need to pay attention to:

  1. After downloading pdfjs, for UWP app, you need to copy the entire folder into the Assets folder, make sure that the folder is named "pdfjs", otherwise you will need to modify the code to change the path.

  2. Your .pdf file should be stored into the Content folder under the Assets folder, it means you will need to create a new folder named "Content" under Assets and copy your .pdf file into this folder. Otherwise, you will also need to modify the code to change the path.

  3. After copying your .pdf file into the "Content" folder, don't forget to change the Build Action of this file to Content like this:

Or what is the correct way to show PDF in UWP?

In uwp app, you can use Image to show PDF file, you can refer to the official PDF document sample. But I don't know if PDF can be displayed as Image in Android and IOS apps, since you're developing a cross-platform project, I think it's better to use the built-in method to solve such problem.

If a demo for xamarin UWP is needed, you can leave a comment, I will upload my demo later.

这篇关于Xamarin Forms UWP - 显示 PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆