PDF generation and shrinking application on high res monitors


#1

We are just starting to understand this new issue, but this is what we know now. We’ll update this as needed.

On Windows 10 (at least) on 4K monitors (at least), when you call GoDiagram’s GoPdfWriter Generate() method, the whole application may shrink. (a lot)

We’ve tracked this to the Microsoft PresentationCore DLL, which apparently sets SetProcessDPIAware when it is loaded. And we use System.Windows.Media.GlyphTypeface in our PDF code… so that’s when the DLL gets loaded.

Now, according to Microsoft (https://msdn.microsoft.com/en-us/library/windows/desktop/ms633543(v=vs.85).aspx) , DLLs should never call this method:

DLLs should accept the dpi setting of the host process rather than call SetProcessDPIAware themselves. To be set properly, dpiAware should be specified as part of the application (.exe) manifest. (dpiAware defined in an embedded DLL manifest has no affect.)

Exactly what to do about this in your application, we’re not so certain. Clearly going through the steps of making your application DPI Aware would seem to be the best path, but that’s outside of the scope of this forum.

One hack is to do this: var gt = new System.Windows.Media.GlyphTypeface();

before your application’s call to InitializeComponent() to force PresentationCore to load before the app sizes itself. But if I do this in the Beatpaths sample… it comes up “small”. If I create a new .NET 4.7.1 app from scratch in VS 2017 and add a GoView and do the same thing… it comes up “big”. No explanation for why the difference right now. But in both apps, nothing weird happens when you call PDF Generate.

The better solution is almost certainly doing the application (.exe) manifest thing discussed in the MS link above.

If any of you have gone through this DPI Aware process in your apps, feel free to share your experience…