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

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

问题描述

请帮帮我,告诉我我想念的是什么.

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

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

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.并且如果唯一的选择是在此处 a>-如何将 pdf.js 添加到我的项目中?

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

推荐答案

我的目标是在WebView控件中显示简单的PDF文件(例如,本地存储).

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

如果要在WebView控件中显示pdf,则

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.

您可以按照xamarin官方文档中的步骤进行操作,这是我们需要注意的一些其他提示:

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

  1. 为UWP app下载 pdfjs 之后,您可以需要将整个文件夹复制到Assets文件夹中,确保该文件夹名为"pdfjs",否则您将需要修改代码以更改路径.

  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.

您的.pdf文件应存储在Assets文件夹下的Content文件夹中,这意味着您需要在Assets下创建一个名为"Content"的新文件夹,然后复制.pdf文件到这个文件夹.否则,您还需要修改代码以更改路径.

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.

将.pdf文件复制到"Content"文件夹后,不要忘记像下面这样将文件的Build Action更改为Content:

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

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

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

在uwp应用程序中,您可以使用Image显示PDF文件,可以参考官方

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.

如果需要用于xamarin UWP的演示,您可以发表评论,我稍后将上传我的演示.

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

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

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