WebBrowser control scaling on hidpi displays - vsto

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?

Related

How can I force an embeded PDF to display at "Page Width" zoom level?

I'm using embed to embed a pdf into my web page. I could also use object or iframe. I want the pdf to open full width of the page, which i have working. But I want the zoom level to be "Page Width". Ive seen several solutions for height, like #view=FitH and some for specific percentages, but not "Page Width"
Most PDF settings are browser specific and subject to user control so here a Chrome based Edge (on the left) and a Firefox based clone (on the right) the biggest problem noticed in these four types of loading is the lack of object support (totally missing in bottom right). Note:- I have security set so only the high speed secured Firefox based plugin viewer will show me PDFs inline without risk of running a script.
However in direct answer to the question not all browsers support the acrobat#tags but most will attempt #zoom=50% (and #page= except perhaps Safari?) whereas fit has frequently been an odd behaviour difference between all of the camps. I show the chrome result below.
the correct tag could be #FitW and that's what I used when chrome unsecured viewing is turned on

VB.net webbrowser control behaving oddly

In Windows Forms, using VB.net (VS 2017 and/or VS 2019), I programmatically create a Webbrowser control in a form to show the contents of a pdf file - it works, but one thing is strange: the pdf appears in the upper-left-hand corner of the Webbrowser, using half the height and half the width of the control (it shows up with scrollbars, so it's still readable).
The rest of the webbrowser control is there, just blank - no reason the pdf should be in just a quarter of the window. If I open the same pdf in any of a number of browsers it appears normally, that is full sized.
The fact that it's using exactly half of the height and half of the width seems to be a clue, but I can see no property or setting that would affect this. Does anyone have any ideas?

How to break a SSRS Report page only in PDF?

I am using BIDS to develop a report that needs to be configured in one page when viewed on the internet explorer but still needs page breaks for good display in PDF when exported. The problem is that when i insert page breaks beetween tables another page is added to the report and i only want that in the PDF. Is there any way i can insert page breaks in the PDF but not on the report view itself?
You can achieve this by setting the InteractiveSize property to the wanted value (0 can be used to make it infinite).
If you wish to keep the same width, then you should only change the Height.
Edit: Defining specific page breaks will always force the viewer to use paging as well. This was implemented to improve the performance of large reports to allows users to begin viewing the initial pages of the report while waiting for additional pages to become available.
HTML and Excel output shows a report as a single page if there are no
page breaks. If you do specify InteractiveHeight and InteractiveWidth,
the HTML and Excel output formats render reports using soft page
breaks. Soft page breaks are placed on a page using an estimated page
size, which makes the size of the reports less exact than reports
produced by an output format that supports page size. Soft page breaks
are calculated at run time by the control. Although it is not
recommended, you can disable soft page breaks by setting
InteractiveHeight to 0.
Source: Defining Page Size and Page Breaks in a ReportViewer Report
As described in the quote above, the InteractiveHeight is used to apply soft page breaking when using the report viewer. So the solution is to only use soft page breaks.
You can manipulate your report to break correctly with paging without using hard page breaks by wrapping the wanted blocks inside rectangles. These rectangles you then re-size to be the size of a page and set the property KeepTogetheras true.
This will try to fit the content of the rectangles on the same page, adding a break when you reach the next rectangle. Because your InteractiveSize has no limit, this will not be displayed in the report viewer.

convert responsive page to pdf with acrobat button

Couldn't decide if this is a question better for Stack Overflow or Superuser, haven't got any bites on Superuser yet...
I have Adobe Acrobat 9.0 Pro, and with that, the Convert Web Page to PDF button that displays in IE. We use this at work to review web pages and comment/markup for changes, etc.
When I use it on a web page that is responsive (such as http://microsoft.com) the resulting PDF shows the page laid out as if the browser window was sized down, but then it stretches all the elements to fit the width of the PDF.
Does anyone know if this is because of the rendering engine the Convert button uses? The resulting PDF looks a bit similar to how the page would look in Quirks mode in IE9 (using F12 developer tools and choosing Quirks mode from the Document Mode drop down.) Thanks for any help!

How to measure text in a RichTextBox in Silverlight

I want to get the height necessary to display the full text in my RichTextBox (when the text extends beyond the set height of the control).
Reminder: Silverlight has no handy TextRenderer.MeasureText like WPF does, nor any other apparent way to measure text.
Doesn't seem like there's any way to do this. I've seen mention of people measuring text of a single font (not mixed as in my RichTextBox) by creating a TextBlock and getting it's Width. Even this doesn't work - it's perfect for some fonts and inconsistent for others.
My app is occasionally connected, so I can't call the server.
As you say, I don't think there's a good way to do this in Silverlight today. There are some functions available in the Document Toolkit by First Floor Software, however those are geared towards working with XPS documents. I'm not sure what you're trying to do, however in Silverlight 5 the RichTextBox does come with the ability to "overflow" text into multiple other RichTextBoxes when the first one cannot display all of the data. This allows you to more easily create a multi-column text layout.
Document Toolkit: http://firstfloorsoftware.com/documenttoolkit
SL5 Video: http://www.silverlight.net/learn/videos/all/silverlight-5-multi-column-linked-text/
SL5 Blog Post: http://10rem.net/blog/2011/04/13/silverlight-5-advancements-in-text