Some test text!

menu
Viewer Controlkeyboard_arrow_down

Implement PDF Viewer Control in UWP app

This guide goes over the steps to implement the Viewer Control in a UWP application

  1. To begin working with ViewerControl, you must have first initialize the PDFTron's UWP SDK by calling pdftron.PDFNet.Initialize("your_key") at the initialization of your application.
  2. Add WinUI 2 resources to the application

    When using WinUI library it is necessary to call it's resource dictionary and add it to the application's resources otherwise the application might crash with a missing resource (style or theme) not found issue

    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
    For more information on starting with WinUI please follow the official Microsoft getting started guide
  3. Enable Share Document Feature by adding runtime directives

    In order to use the Share feature, it is necessary to add System.Collections.Generic.List{} directive to the Default.rd file

    <Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
    <Application>
        <!--
        An Assembly element with Name="*Application*" applies to all assemblies in
        the application package. The asterisks are not wildcards.
        -->
        <Assembly Name="*Application*" Dynamic="Required All" />
        
        
        <!-- Add your application specific runtime directives here. -->
        <Type Name="System.Collections.Generic.List{}" MarshalObject="Required All"/>
    
    </Application>
    </Directives>
  4. Add ViewerControl to a page

    ViewerControl can be easily added to a UWP App page.

    <Page
        x:Class="MyUWPApp.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:viewer="using:pdftron.PDF.Tools.Controls.Viewer"
        mc:Ignorable="d">
    
        <viewer:ViewerControl/>
    </Page>
  5. Check the ViewerControl sample app

    You can also check a sample project that implements the ViewerControl

Get the answers you need: Support

close

Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.