Implement PDF Viewer Control in UWP app
This guide goes over the steps to implement the Viewer Control in a UWP application
To begin working with
ViewerControl, you must have first initialize the Apryse's UWP SDK by callingpdftron.PDFNet.Initialize("your_key")at the initialization of your application.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
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>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
<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>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 ->Resourcesand add the filespdftron_exotic_font_resources.plugin,pdftron_layout_resources_.plugin, andpdftron_smart_substitution.plugin. For each file, right click the file and clickpropertiesand change theBuild ActiontoContent.More information on MS Office Conversion guides.Add ViewerControl to a pageViewerControl can be easily added to a UWP App page.
Check the ViewerControl sample appYou can also check a sample project that implements the ViewerControl
Last updated
Was this helpful?