License Key

Setting the license key can be done either by setting the License in the PdfView or programmatically in code by calling the appropriate method.

License Key PdfView Property

You can set the value of the License either directly in your XAML or indirectly by referencing a resource, as in this example:

1
<ui:PdfView Grid.Row="0" Name="PdfView" License="{StaticResource PSPDFKitLicense}" />

You can define the static resource string like this:

Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<Application
    x:Class="MyApp.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    >

+   <Application.Resources>
+       <ResourceDictionary>
+           <ResourceDictionary.MergedDictionaries>
+               <ResourceDictionary>
+                   <x:String x:Key="PSPDFKitLicense">YOUR_LICENSE_KEY_HERE</x:String>
+               </ResourceDictionary>
+           </ResourceDictionary.MergedDictionaries>
+       </ResourceDictionary>
+   </Application.Resources>

</Application>

Programmatically Setting the License Key

If setting the license in code, you must call Sdk.Initialize before using any other PSPDFKit API or instantiating any PdfViews.

An ideal place to do this is in the App constructor, as shown in this example:

1
2
3
4
5
6
public App()
{
  this.InitializeComponent();

  PSPDFKit.Sdk.Initialize("YOUR_LICENSE_HERE");
}