Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
VB6: Taking screenshot of the displayed webpage
#1
Hi Wil

I would like to ask if you are planning to add the CapturePreviewAsync method 
that is currently implemented in WebView2 (v1.0.1901.177)

I've read on Microsoft's site, the method allows you to save a image of the page in a PNG or JPG file. 
That's exactly what I need. 

I currently print the website to a PDF file. After that I open the PDF file in the background and take a screenshot.

Using CapturePreviewAsync method would be simpler Smile

Best regards
Przemek
Reply
#2
Hi Przemek,

Sorry for the late reply, missed this post somehow.

This is a feature we have looked into in the past. CapturePreviewAsync has actually been in WebView2 for a long time.
The problem is that it uses an image stream, so it doesn't exactly write to a file, it writes to a stream and most of the tools that use AntView don't support writing to a stream.

I agree that having this feature will be great and it certainly is on the list of things to investigate on how-to add support for this feature.

--
Wil
Reply
#3
Hi Przemek,

Just looked into this and it now works and will be available in the next version.
If interested then I can get you a preview version to test.

However do note that the "preview" that it takes is only the part that is currently viewed in the browser, including the scrollbar itself if any.

If you are looking for a png/jpeg image version of the complete page as it is rendered when you scroll down the page.. that's not what this is. Microsoft only gives you an image of what you're seeing in the webview2 control.

--
Wil
Reply
#4
Hi,

This is now available in the released version, 1.1.314.

Hope this helps,
--
Wil
Reply
#5
(2023-08-31, 16:05:14)wila Wrote: Hi,

This is now available in the released version, 1.1.314.

Hope this helps,
--
Wil

Hi Wil

Thank you for the explanation and I will be happy to try the new method

--
Regards Przemek
Reply
#6
(2023-08-31, 16:05:14)wila Wrote: This is now available in the released version, 1.1.314.

Hi Wil. I try this method

Code:
AntView.CapturePreview "D:\file.jpg", cpifJpeg


It saves file but I have encountered a problem "Function or interface marked as restricted, or the function uses an Automation type not supported in Visual Basic." 

This message appears when I want to catch this event "OnCapturePreviewCompleted". Probably the reason is 32-bit VB6

Code:
Sub AntView_OnCapturePreviewCompleted(ByVal errorCode As Long)
Debug.Print "errorCode: " & errorCode
End Sub


Immediately after execution the CapturePreview method, bellow an error appears

Code:
Private Sub AntView_OnProcessFailed(...)
  ExitCode: -1073741819
  ProcessDescription: 6
  Reason: 3
End Sub


Despite the error, the screenshot is saved into a file

--
Regards Przemek
Reply
#7
Hi,

Oh dear. We used HResult as return type as it was what was passed from the WebView2 control.
Then tested the functionality on another development platform as VB6.

If long was used (int32) then it would have been no problem and the exact same data could be returned.
I will see if I can reproduce and then decide on what the best solution is.

Thanks for the report.
--
Wil
Reply
#8
Hi,

The issue was reproduced and I just released AntView 1.1.316 where the parameter has been corrected to use datatype long (Int) instead of HResult.

This fixed the issue on our side.

Thanks again for the report.
--
Wil
Reply
#9
(2023-09-04, 07:50:12)wila Wrote: This fixed the issue on our side.

Great news. Thank you.
I'll test today and if anything is wrong I'll let you know.

--
Przemek
Reply
#10
(2023-09-04, 09:50:02)MrPrzemek Wrote:
(2023-09-04, 07:50:12)wila Wrote: This fixed the issue on our side.

I confirm. The bug does not occur in this version. Thank you for quick fix Smile

--
Przemek
Reply
#11
Cool thanks for confirming that the issue is also resolved on your end.
--
Wil
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)