Search code examples
c#xamlwindows-10-universalpdftron

Exception thrown when navigating to a page with PDFTron


I have to say this exception is really weird. In Windows 10, universal C#-XAML app. I have two monitors (the one from the laptop, and a 2nd screen) and a surface. I have a very simple app, with 2 pages, PageA and PageB. If I put the the PDFTron logic from the samples provided in PageA, it works in all 3 screens. If I put the PDFTron logic in PageB and use the laptop monitor WITHOUT having changed anything it breaks and throws a helpful "Unknow error!". If I use the same app in my 2nd monitor or the surface it works!!

I call

 pdftron.PDFNet.Initialize();

In the App.xaml.cs and build PDFViewCtrl = new PDFViewCtrl(); in the UI thread in the constructor of PageB.

any help please?

PDFTron sample

Be aware that the sample works in certain conditions as a Surface. But in a 3840x2160 Dell laptop screen puting the logic in PageB it does not work.


Solution

  • First, there is most likely an actually useful exception message, but you have to retrieve it from PDFNet using the exception you got. See this blog post. This is a limitation of how Microsoft implemented their latest mobile technology (COM API boundary).

    As for the error, most likely this has already been fixed. Windows 10 introduced pixel densities that are not recognized in the Windows.Graphics.Display.DisplayProperties.ResolutionScale enumerator from Windows 8.1.

    This is why certain devices would fail, and others would not, using older versions of PDFNet.

    Please contact PDFNet support to get the latest version.