Xamarin Forms UWP - Display PDF

前端 未结 1 624
长情又很酷
长情又很酷 2021-01-03 14:07

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

1条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-03 14:08

    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.

    0 讨论(0)
提交回复
热议问题