How to view the pdf file from MAUI?

Sowndarrajan Vijayaragavan 450 Reputation points
2023-06-18T15:25:30.0433333+00:00

I need to view the pdf file in my MAUI application.

Dedicated popup page to view my pdf file with Zoom, pan controls

Target platform - Windows

Developer technologies .NET .NET MAUI
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2023-06-19T03:00:39.3433333+00:00

    Hello,

    You can use webview to show the pdf file.

    Firstly, you can copy pdf file to Resources\Raw\ path and make sure pdf file's Build action is MauiAsset

    Then, you can use the following code to show your pdf file.

    <?xml version="1.0" encoding="utf-8" ?>
    <toolkit:Popup  xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                   xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
                 x:Class="MauiShowPDF.SimplePopup"
                 >
    
           <Grid >
                
                <WebView Grid.Row="1" HorizontalOptions="Fill" VerticalOptions="Fill" Source="maui.pdf" />
            </Grid>
                
    </toolkit:Popup>
    

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.