Save complete page in htmlviewer as jpg

  1. you dont - there is no intrinsic height or width for a web page - so you tell chrome how big you want the image and it does its thing. you can control the size of the layout that it takes a picture of but again there is no way to know ahead of time (just like if you open a browser window it opens at whatever size the browser opens it NOT at whatever size the web page says it should be)

  2. it does - or firefox - either works
    I have not checked opera as well but between chrome, ff, opera and IE you probably handle most browsers

the app I’m working on also has tried to use webkit and IE with and without MBS and had mixed results

I can get the height fine with Delphi and TWebBrowser, using IHTMLElement2 and the scrollheight property of it, and the image is always the whole page. I set the browser to that height, the moment it has to create the image, then I create the image and its a 100% match. And thats what I try to replicate with Xojo, NOT using external browser which might not be installed on the clients PC.
If thats not possible, its also ok.

I check the sample example and it works fine here, with 150% or 300% DPI no problem.
You can send me an email to get the new example.

Code is like this:

[code]// resize web viewer to show full website without scrolling

Dim doc As IEDocumentMBS = web.IEDocumentMBS

If doc <> Nil Then

Dim w As Integer = web.Width
Dim h As Integer = web.Height

web.Width = doc.ScrollWidth + 24
web.Height = doc.ScrollHeight + 24

// now get picture
pic = doc.Image

// restore size
web.Width = w
web.Height = h

out.Invalidate

Else
MsgBox “No website loaded?”
End If[/code]

So we resize htmlviewer to avoid scrollbars and then render image.

@Christian Schmitz The more serious problem is, that the htmlviewer does not render pages properly. On some pages, images are just not there, or the whole layout is not right, so I wont be able to use htmlviewer with native browser selected. The pages are looking correct when using Webkit, but then the IExxx of your plugin wont work. So I am running in circles somehow.

Sorry to hear. You can try e.g. Xojo 2019r1 with our ChromiumBrowserMBS class to render an image there.

[quote=471438:@Guenter Kraemer]I can get the height fine with Delphi and TWebBrowser
[/quote]
Sure but Xojo is not delphi so …

When htmlviewer use the IE engine, why cant it render pages correct, but IE can (or other IE based browser or wrapper)?

Can anybody answer this?

Doesn’t help, I already did that, makes no difference.

There’s a dramatic difference between the default IE 7 rendering engine and IE 11 - so if nothing changed, then you aren’t doing it correctly.

Can you show us your sample code for setting the registry items?

with latest MBS Plugins, you can use this code:

[code]// make sure we don’t end up with Internet Explorer in version 7, which is default.
Dim v As Integer = IEWebBrowserMBS.GetInternetExplorerVersion

If v < 11000 Then // below version 11.0

Dim b As Boolean = IEWebBrowserMBS.SetInternetExplorerVersion(11000)
If b Then
MsgBox “Requested Internet Explorer version 11.0.”
Else
MsgBox “Failed to set IE version?”
End If
End If[/code]

We added IEWebBrowserMBS.SetInternetExplorerVersion to help with our new Evaluate function to work properly.

[quote=471920:@Michael Diehr]There’s a dramatic difference between the default IE 7 rendering engine and IE 11 - so if nothing changed, then you aren’t doing it correctly.

Can you show us your sample code for setting the registry items?[/quote]

There is nothing to show, I have set them “by hand”, not by code.
The .exe is test.exe, I set a key/value in HKCU/SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION with a name of test.exe and a DWORD value of 11000 (I also tried 11001). I rebooted to be sure, and nothing changed in htmlviewer, page still wont get rendered properly.

I am quite sure you know, but:

https://en.wikipedia.org/wiki/Internet_Explorer#End_of_life

That makes Edge 5 y/o by tomorrow ! :wink:

Still IE ActiveX component is widely used for embedded browser, so this may be there for next ten years.

[quote=471946:@Emile Schwarz]I am quite sure you know, but:

https://en.wikipedia.org/wiki/Internet_Explorer#End_of_life

That makes Edge 5 y/o by tomorrow ! ;)[/quote]

Yes, but there is currently no other way than to use IE, if you want to make a full page screenshot, not just the visible area. I could never get that to work with Chromium (or Webkit in Xojo).

So, you will ask your users to use IE ?

[quote=471942:@Guenter Kraemer]There is nothing to show, I have set them “by hand”, not by code.
[/quote]
As a test, point your HTMLViewer at this page https://www.whatismybrowser.com/detect/what-is-my-user-agent and see what the userAgent string says.

With the IE7 renderer under Windows 10 it shows something like this:

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E)

With the IE11 renderer under Windows 10 it shows something like this:

Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko

You need also to add this in your HTML page:

[quote]
[/quote]
And also use HTML5 DOCTYPE at the start of the document:

Then not only will the IE-11 renderer be loaded, but it will render as IE-11 and not IE-7.

It took me a lot of time experimenting and web-searches to discover that this is necessary, which is why I asked for it to be added to the HTMLviewer docs.

The registry changes make the IE-11 renderer load. The addition here makes it work properly.

[quote=471972:@Tim Streater]You need also to add this in your HTML page:

And also use HTML5 DOCTYPE at the start of the document:

Then not only will the IE-11 renderer be loaded, but it will render as IE-11 and not IE-7.

It took me a lot of time experimenting and web-searches to discover that this is necessary, which is why I asked for it to be added to the HTMLviewer docs.

The registry changes make the IE-11 renderer load. The addition here makes it work properly.[/quote]

The page ist not my page, so how shall I change the code in it? Anyway, I will give up with this for now.