> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/uwp/viewer/using-viewercontrol.md).

# Implement PDF Viewer Control in UWP app

Learn how to implement Viewer Control in a UWP application with this comprehensive guide. Initialize Apryse's UWP SDK, add WinUI 2 resources, enable Share Document Feature, and support MS Office Conve

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 Apryse's UWP SDK by calling `pdftron.PDFNet.Initialize("your_key")` at the initialization of your application.
2. Add WinUI 2 resources to the applicationWhen 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

{% tabs %}
{% tab title="XML" %}
{% code lineNumbers="true" %}

```xml
<Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% hint style="info" %}
For more information on starting with WinUI please follow the official [Microsoft getting started guide](https://docs.microsoft.com/en-us/windows/apps/winui/winui2/getting-started/)
{% endhint %}

1. Enable Share Document Feature by adding runtime directivesIn order to use the Share feature, it is necessary to add `System.Collections.Generic.List{}` directive to the Default.rd file

{% tabs %}
{% tab title="XML" %}
{% code lineNumbers="true" %}

```xml
<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>
```

{% endcode %}
{% endtab %}
{% endtabs %}

1. Enable support for MS Office Conversion by adding the required resource files to the project. To do this go into the solution explorer, right click your solution, and click `Add` -> `Existing Item...`. Go to the UWP SDK folder -> `Resources` and add the files `pdftron_exotic_font_resources.plugin`, `pdftron_layout_resources_.plugin`, and `pdftron_smart_substitution.plugin`. For each file, right click the file and click `properties` and change the `Build Action` to `Content`.More information on [MS Office Conversion guides](/uwp/ms-office/convert-office.md).
2. Add ViewerControl to a pageViewerControl can be easily added to a UWP App page.

{% tabs %}
{% tab title="XML" %}
{% code lineNumbers="true" %}

```xml
<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>
```

{% endcode %}
{% endtab %}
{% endtabs %}

1. Check the ViewerControl sample appYou can also check a [sample project](https://github.com/ApryseSDK/pdftron-uwp-samples/tree/master/PDFViewerControl/) that implements the ViewerControl


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/uwp/viewer/using-viewercontrol.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
