Version 10
Version 9
Version 8
Version 7
Version 6
Please refer to either Download and integrate manually or Integrate with NuGet guide.
Now that the project is set up, let us add a PDFViewCtrl as the main feature of the project. First, we need to set up the page to contain the PDFViewCtrl. We want to add a main viewing area for the PDFViewCtrl, and an area at the bottom where we can later add in some options. Open up “MainPage.xaml” and find the Grid element. Add some row definitions as follows:
The second row will be used for our options bar, while the first row will use whatever space is left to display the PDFViewCtrl.
To this Grid, let's add a Border which will host the PDFViewCtrl and then a stack panel with a button to open a document.
Now, we want to add the PDFViewCtrl to the app. We do this in “MainPage.xaml.cs”. Open up “MainPage.xaml.cs” and add a member variable that references a PDFViewCtrl.
Next, we need to initialize PDFNet and create a PDFViewCtrl, so let's do this in the constructor of the MainPage. We also need to make the PDFViewCtrl the child of the PDFViewBorder.
We also have to add a handler for the Open button. Let's do that in MainPage's constructor after we have created a PDFViewCtrl.
Inside this click function, we need to open a Document. First, let's include two new namespaces that we need for the file picker and for the storage file.
Also, OpenButton_Click needs to be async in order to handle some of the asynchronous API's needed here. So, replace the old OpenButton_Click with the following:
Build and launch the app and we should now have a very basic PDF document viewer.
Do note that in Windows 8.1, the file picker works differently. Please see this guide for how to use file pickers in Windows Phone 8.1: https://msdn.microsoft.com/en-us/library/windows/apps/dn642086(v=vs.105).aspx
The basic viewer doesn't support text selection, for example, out of the box. For this, we will need the tools package from NuGet or the tools project contained in the download package.
If you integrated PDFTron.UWP using NuGet then use the tools package PDFTron.UWP.Tools
in the package manager.
Find your project in the Solution Explorer. Right Click on the project and click on Manage NuGet Packages...
. In the package manager, select the Browse tab and search for PDFTron.UWP.Tools
. Install this package.
If you integrated manually with the Apryse UWP download package then use the tools package in the samples folder from the download.
Add
-> Existing Project...
. Navigate to the folder where the PDFNet package was unzipped, Open the Lib Folder, Framework Folder and then the Tools_VS2019 Folder. Inside here you should find Tools_VS2019.csproj. Select it and select Open.Manage NuGet Packages
then select PDFTron.UWP
-> Uninstall
.Add Reference...
In the dialog, select Project
-> Solution
and find Tools_VS2019 in the list. Select it and add it by clicking OK.Add Reference...
. In the left pane of the dialog, select Universal Windows
. Then select Extensions
and in the list that appears, check the box next to PDFNet SDK for UWP
.Inside the constructor for MainPage we now add one more call where we initialize the ToolManager.
This is all you need for text selection to work. The tools support many other operations, such as creating and adding basic shapes to the PDF document and editing form fields.
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales