This is a migrated thread and some comments may be shown as answers.

Problem with screen scale factor > 100%

3 Answers 1590 Views
PdfViewer and PdfViewerNavigator
This is a migrated thread and some comments may be shown as answers.
pierre-jean
Top achievements
Rank 1
Veteran
Iron
pierre-jean asked on 14 Sep 2020, 12:49 PM

Hello

I have a pdf Viewer in a usercontrol that is itself loaded in my main windows form

When I have my screen set to a scaling factor larger than 100%, the whole application is resized when I load a document in the pdfviewer.
The usercontrol that hosts the viewer has autoscale set to none (like all the other elements of the project)
all other forms and elements behave normally under scale factor larger than 100%

the attached screen copy shows the change of size (for test purpose I have set my screen scale factor at 200%)

Thanks in advance for any suggestion

Best regards

Pierre-Jean

3 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 15 Sep 2020, 04:30 PM

Hello Pierre-Jean,

The observed behavior is caused by the application which suddenly becomes DPI-aware because of the increased Windows scaling. Creating PDF files will result in initiating a type from our Document Processing Libraries. These libraries internally reference WPF types. WPF in contrast to WinForms is DPI-aware technology by design and accessing such types at run-time will make you WinForms application DPI-aware which will cause scaling as the one observed by some of your users. We have a blog post discussing this in details: https://www.telerik.com/blogs/winforms-scaling-at-large-dpi-settings-is-it-even-possible.

In order to resolve this you have two options: 

  1. Develop your WinForms application to be DPI-aware. This way it will scale properly when it is run on systems having high DPI. Using the PdfViewer control will not cause additional scaling as the application would have been scaled on startup. We have introduced HDPI support in the suite and you can enable it by following the instructions in this documentation article: https://docs.telerik.com/devtools/winforms/telerik-presentation-framework/dpi-support.
  2. Do not create a DPI-aware application and avoid the observed scaling. The only way to prevent this is to use the approach suggested in the blog post. Please refer to the DPI Awareness and Document Processing Libraries section.

I hope this will help. Let me know if you have other questions.

Regards,
Hristo
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).

0
pierre-jean
Top achievements
Rank 1
Veteran
Iron
answered on 16 Sep 2020, 02:11 PM

Hello Hristo

thank you for your reply.

I have tried to follow the instructions of:

https://docs.telerik.com/devtools/winforms/telerik-presentation-framework/dpi-support 

and I still have the same problem.

Here are the extracts of my app.config and my app.manifest file, as far as I can see they match the referenced link

All my forms have the property autoscalemode set to None

I may be missing something but I fail to see what ...

Thanks in advance for your advice

 

Best regards

Pierre-Jean

--------------------------------------------APP.CONFIG -------------------------------------------------------

  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
  </startup>
  <System.Windows.Forms.ApplicationConfigurationSection>
    <add key="DpiAwareness" value="PerMonitorV2" />
    <add key="DisableDpiChangedMessageHandling" value="True" />
  </System.Windows.Forms.ApplicationConfigurationSection>

-----------------------------------------------------APP:MANIFEST--------------------------------------------------------

<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
  <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
      <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
    </application>
  </compatibility>
</assembly>

--------------------------------------------------------------------------------------------------------

0
Hristo
Telerik team
answered on 17 Sep 2020, 03:39 PM

Hi Pierre-Jean,

It looks like that you have declared the application as dpi-aware. In that case, the app should scale once upon startup or when you move a window to a screen with different DPI. Opening a document in the PdfViewer should not cause any additional scaling.

From your last post, I understand that you are still having the issue. It may be caused if the DPI awareness is not declared properly. Please note however, that the app.config and manifest files you shared are suitable for .NET 4.7 and Windows 10 Creators update. In case it is not working on you end, you can also try setting the DPI awareness using only the manifest file as per the documentation article: https://docs.telerik.com/devtools/winforms/telerik-presentation-framework/dpi-support#how-to-enable-hdpi-support-in-your-application.

In case you don`t to want to make the application DPI aware, you can use the approach with the native dlls as per the DPI Awareness and Document Processing Libraries in the article here: https://www.telerik.com/blogs/winforms-scaling-at-large-dpi-settings-is-it-even-possible-

I hope this will help.

Regards,
Hristo
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).

Moe
Top achievements
Rank 1
Iron
Iron
Veteran
commented on 26 Apr 2022, 07:52 AM

HI Hristo,

 

I don't want to add below method.

<System.Windows.Forms.ApplicationConfigurationSection> <add key="DpiAwareness" value="PerMonitorV2" /> </System.Windows.Forms.ApplicationConfigurationSection>

 

Because I added, whole project of setting are changed. And some are alignment out when I used small to large screen. Do you have other method to solve these issue. Because last time don't have these issue. After update telerik , I will get these issue. Last time I didn't update telerik for two years and I can use RadPdfViewer.LoadDocument and these part no issue for that. Now After load radpdfviewer1.loadcoucment, all of form screen are changed and scale change similar like above issue.

 

 

Thanks,

moe

Dess | Tech Support Engineer, Principal
Telerik team
commented on 26 Apr 2022, 09:09 AM

Hi, Moe,

Please refer to the following KB article which demonstrates different approaches for handling this case:

https://docs.telerik.com/devtools/winforms/knowledge-base/app-becomes-dpi-aware 

If you don't want any scaling to be performed, feel free to use the second suggested option with declaring the application as DPI unaware.

Moe
Top achievements
Rank 1
Iron
Iron
Veteran
commented on 26 Apr 2022, 09:23 AM

HI Dess,

 

I got below issue .

 

 

 

Thanks,

Moe

Moe
Top achievements
Rank 1
Iron
Iron
Veteran
commented on 26 Apr 2022, 09:25 AM

Hi Dess,

 

Please ignore it above error of Enum question.

 

Thanks,

Moe

Moe
Top achievements
Rank 1
Iron
Iron
Veteran
commented on 26 Apr 2022, 09:32 AM

HI Dess,

Thank you for helping. Now I got it.

 

Thanks,

Moe

Tags
PdfViewer and PdfViewerNavigator
Asked by
pierre-jean
Top achievements
Rank 1
Veteran
Iron
Answers by
Hristo
Telerik team
pierre-jean
Top achievements
Rank 1
Veteran
Iron
Share this question
or