VB.net webbrowser control behaving oddly - vb.net

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?

Related

Make VB.NET app DPI Aware (Visual Studio 2012)

I'm trying to make an image file from a control using CopyFromScreen, and it fails unless I set the scale to 100%. With a larger scale the image is progressively offset left and up, the further right and down the window is on the screen. (Unfortunately my eyes struggle at 100%)
I initially tried using DrawToBitmap but that fails as there's a rich text box in the control and it's documented that that won't paint.
I've read articles on this forum and followed the suggestion of including the dpiAware setting in the manifest, but that has no effect. I'm no expert and I'm wondering if it's because I only have VS 2012 and my manifest declaration starts with asmv1 rather than asmv3 so I had to amend the example code?
Any suggestions most welcome.

WebBrowser control scaling on hidpi displays

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?

Expanding textbox stopping page breaks in PDF conversion

I have a simple report that has an image and a textbox within the body (a rectangle). The textbox is set to 'Allow Height to Increase'. The rectangle is set to 'Page Break After'.
Normally this works fine if the contents of the textbox span a few lines. However, when the textbox expands over multiple pages the Page Break is ignored. This only happens when exporting to PDF, yet works as expected in Preview mode.
I'm hoping someone has some insight into this behaviour or can recommend an alternative page structure that will achieve the desired results.
Could you please check the Rectangles property
kept contents together on a single page
in a parent Rectangle object, this will always keep items together where possible.
You could also set page setup settings (margins, gutters, printable page size...) to make sure that they are not affects on exported PDF document.

Extract screenshot or picture of portion of PDF using VBA or VB and Adobe SDK

I am currently using an excel macro (although I will switch to VB.NET if necessary) to loop through all of the text in a PDF and populate an array with certain portions of the text in the PDF (via the Adobe SDK and getPageNthWord). This part is working just fine, but now what I want goes a step further.
There are certain portions of the PDF where just grabbing the text isn't giving the full picture, and I'd like to see what more I can get. This is exactly the screenshot or snippet I am trying to get:
So, I know that I could use getPageNthWordQuads to find the coordinates for the words "Compliance Warning" and I could figure out a way to find the bottom right of the screen as well, but my problem starts there. After I get those coordinates what would I do with them? Can I zoom in the PDF to only see that portion and then take a screenshot? I already have the code for a screenshot of the activewindow, but I don't know how to scroll or zoom on a PDF.
Any help would be greatly appreciated. A fresh approach would be welcome as well. Thanks!
There are probably a number of approaches that would work - I don't know enough about your environment / constraints to know for sure which would work best. I'm assuming you are talking to Acrobat through OLE here.
1) You can open a window, get its AVPageView and ask it to zoom and move to where you want it to do your thing.
2) You can open a PDF document in one of your own windows using OpenInWindowEx and then grab the contents of that window (the advantage being that this window could be off screen).
3) You can use the DrawEx method (in AcroExch.PDPage) to render a specific portion of a page into your own window and then process that.

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