3

We're currently building an add-in to host an some html content as a VSTO add-in for Outlook. However, on a hidpi display the scaling factor for the WebBrowser control is incorrect. Instead of scaling based on the scaled displayed percentage (250% on a 4k 15in display) it's leaving the scaling at 100%. I've verified this by querying window.devicePixelRatio which is just returning 1.0.

I've tried using an answer described here: https://social.msdn.microsoft.com/Forums/en-US/151dcd48-4f09-4701-aa10-edc34617e7f2/how-to-zoom-a-web-browser-programatically-in-c?forum=csharpgeneral which applies zoom on the WebBrowser control itself however only text elements appear to zoom.

I've also tried applying a zoom style on the HTML document itself from the WebBrowser control webBrowser.Document.Body.Style = "zoom: 150%;"

When hosting the same code in a standalone WinForms application, window.devicePixelRatio is the expected value of 2.50 and everything just works.

Are there any known workarounds other than those described above?

Cindy Meister
  • 25,071
  • 21
  • 34
  • 43
rgmills
  • 383
  • 1
  • 8
  • Might be related to [VSTO custom taskpane on multi DPI system shows content twice](https://stackoverflow.com/questions/50100564/vsto-custom-taskpane-on-multi-dpi-system-shows-content-twice) – Chris Aug 06 '18 at 14:47
  • Just wondering, is there any reason you are not using web add-ins with Office.js? If you're hosting a web page, it seems like you're almost there. – Outlook Add-ins Team - MSFT Aug 06 '18 at 15:55
  • To clarify, I believe dynamic DPI is supported in web add-ins. – Outlook Add-ins Team - MSFT Aug 06 '18 at 16:00
  • Some text elements weren't scaling correctly since there was no explicit `font-size` specified. I'm not sure what values they were inheriting or where they were coming from. Once applied, zoom on the WebBrowser control worked fine. – rgmills Aug 06 '18 at 18:43
  • 2
    We have customers with older Exchange deployments, I'm using the same codebase as our web add-ins though :) – rgmills Aug 06 '18 at 18:43

0 Answers0