Detect actual size of HTML content in a WebBrowser control

Is it possible to determine the height / width of content in a WebBrowser control? I would like to keep the contents of the image, but only with the size of the actual content.

Thanks in advance.

+4
source share
2 answers

I believe that you can get it from the following property:

myWebBrowser.Document.ScrollRectangle.Size; 

Being an object of System.Drawing.Size .

+4
source

The document recounts the layout every time the browser window is resized, so it really does not have a fixed size.

You can use the golden section search to find the minimum window size large enough to hold a document, but this is a processor intensive task.

+1
source

Source: https://habr.com/ru/post/1308063/


All Articles