For the complete documentation index, see llms.txt. This page is also available as Markdown.

Printing a document with UWP

Apryse's UWP PDF library supports printing. The library handles all the hard work, you simply have to tell it to register and what options you would like to be available.

  1. First, we have to add a PDFPrintManager. Declare another member variable in MainPage.xaml.cs next to MyToolManager.The PDFPrintManager is a singleton, so let's grab it at the bottom of MainPage's constructor, under OpenButton.Click.

pdftron.PDF.PDFViewCtrl MyPDFViewCtrl;
pdftron.PDF.Tools.ToolManager MyToolManager;
pdftron.PDF.PDFPrintManager MyPrintManager;

MyPrintManager = pdftron.PDF.PDFPrintManager.GetInstance();

2. Now, we need to add localized string options. Because the printer options are handled by the library, it needs to provide the option of localization. Inside the Lib folder there is a folder called strings that contains the string resources for American English (en-US).

Right click on PDFNetSample, select **Add** -> **New Folder**. Name this folder strings. The right click on the strings folder, again select **Add** -> **New Folder**. Name this folder en-US. From the downloaded package, go to the folder Lib -> strings -> en-US and drag the file Printing.resw into the en-US folder you created in the Sample project.

![localizedstrings](./img/localizedstrings.bmp)
Adding localized strings to the project for Printing.

Once done, your solution explorer should show look as follows.

![solutionwithlocalizedstrings](./img/solutionwithlocalizedstrings.bmp)
Solution explorer with localized strings.

Also, we need to tell the PDFPrintManager where to find this resource. In the constructor for MainPage, we can add the following two lines of code below where the PDFPrintManager is initialized.

```csharp

Windows.ApplicationModel.Resources.ResourceLoader loader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView("Printing");
MyPrintManager.SetResourceLoader(loader);

At this point, printing should be added to the sample.

Last updated

Was this helpful?