^ What's the point?
^ Requirements
^ Licenses
^ Installation
^ Usage
^ Using the thumbnail functions
^ HResult error codes
^ COM class functions
^ DLL functions

Download :: Top
WebPage Snapshot Library

WebPage Snapshot Library is a COM/DLL component that uses MS Edge WebView2 to create snapshot pictures of URLs, for use in Win32 and Win64 (Windows 10/11) software.

Features:
  • Create picture snapshots of URLs or local HTML files
  • Set snapshot picture width and height
  • Capture to PNG file or to a bitmap handle
  • Get a thumbnail of the page to PNG file or to a bitmap handle
  • Supports using the WebPageSnapshot.dll itself natively without COM with a direct DLL call, Delphi and C++ API headers included



Requirements

Developer environment/platform supporting COM classes or DLLs.
Windows 10 or above with Edge browser installed.


WebPage Snapshot Library in shareware and commercial software?

The library can be avaluated freely, there are no limitations. If you like this component and use it in a freeware, shareware or commercial (or any other money making - advertising, in app. selling, etc.) product one of the licenses is needed.


Installation

If you install the library with the setup.exe the COM classes will be registered automatically. In other cases the COM classes need to be registered manually (don't forget to perform the regsvr32.exe in administrator mode!). When you distribute your app. the COM classes must be registered too on the user's computer.

Inno setup example:
[Files]
Source: "E:\WebPage Snapshot Library\Setup files\Bin\Win32\WebPageSnapshot.dll"; DestDir: "{app}\Bin\Win32"; Flags: regserver 32bit
Source: "E:\WebPage Snapshot Library\Setup files\Bin\Win64\WebPageSnapshot.dll"; DestDir: "{app}\Bin\Win64"; Flags: regserver 64bit; Check: IsWin64
Manual registration: Run an elevated command prompt, change dir into the folder where 'WebPageSnapshot.dll' is located, run the following: "regsvr32 WebPageSnapshot.dll". This should register the COM class. Do this for the desired Win32 and/or Win64 version.
For using the library 'WebView2Loader.dll' is needed on the search path.
To use the library in VBScript, on a 64 bit OS, the VBScript process is 64 bit so the needed DLLs have to be from the Win64 folder, beside the .VBS file or in the 'System32' folder as written above.


Usage

After registering the DLL it can be accessed like this (VBScript):
	option explicit
	dim myobject
	set myobject = createobject("WebPageSnapshot.CreateSnapshot")
	myobject.SetDataFolder "E:\DATAFOLDER"
	myobject.CreateSnapshotFile 1920, 1080, "https://www.3delite.hu", "E:\WebViewSnapshot.png"
	set myobject=nothing

Using the thumbnail functions

The 'ThumbnailWidth' and 'ThumbnailHeight' parameters are not absolute values, the input picture is resized while keeping the aspect ratio to fit in these dimensions.
If an exact thumbnail size is needed specify the 'Width' and 'Height' parameter as to have the same aspect ratio as the needed thumbnail's aspect ratio.


HResult error codes
  • S_OK: Success.
  • S_FALSE: Unknown error occured or catastrophic failure.

COM class functions
  ICreateSnapshot = interface(IUnknown)
    ['{E09EED5E-D619-4625-9C38-E76FC208EC4F}']
    function SetDataFolder(Folder: OleVariant): HResult; stdcall;
    function CreateSnapshotFile(Width: Integer; Height: Integer; URL: OleVariant; FileName: OleVariant): HResult; stdcall;
    function CreateSnapshotHandle(Width: Integer; Height: Integer; URL: OleVariant; out BitmapHandle: OleVariant): HResult; stdcall;
    function CreateSnapshotThumbnailFile(Width: Integer; Height: Integer; ThumbnailWidth: Integer; ThumbnailHeight: Integer; URL: OleVariant; FileName: OleVariant): HResult; stdcall;
    function CreateSnapshotThumbnailHandle(Width: Integer; Height: Integer; ThumbnailWidth: Integer; ThumbnailHeight: Integer; URL: OleVariant; out BitmapHandle: OleVariant): HResult; stdcall;
    function Get_LastError(out Value: Integer): HResult; stdcall;
    function Get_LastErrorMessage(out Value: OleVariant): HResult; stdcall;
    function Get_LastPageLoadTime(out Value: Integer): HResult; stdcall;
    function Get_LastPageSnapshotTime(out Value: Integer): HResult; stdcall;
  end;
Before using the snapshot functions, first always set the data folder. It's the folder where Edge stores eg. the cookies and browsing releated stuff - starts with ~20 MB on first navigation.
The 'Folder', 'URL' and 'FileName' parameters are string values.
The 'Handle' functions return a Windows standard 'HBitmap' handle in 'BitmapHandle'.
Use the 'LastError' property to get the last error code (success) for environments that don't support the function's 'HResult' return value type.


DLL functions
    function WebPageSnapshot_CreateSnapshotFile(DataFolder: PChar; Width: Integer; Height: Integer; URL: PChar; FileName: PChar; WPSLog: PWPSLog): HResult; stdcall;
    function WebPageSnapshot_CreateSnapshotHandle(DataFolder: PChar; Width: Integer; Height: Integer; URL: PChar; var BitmapHandle: HBitmap; WPSLog: PWPSLog): HResult; stdcall;
    function WebPageSnapshot_CreateSnapshotThumbnailFile(DataFolder: PChar; Width: Integer; Height: Integer; ThumbnailWidth: Integer; ThumbnailHeight: Integer; URL: PChar; FileName: PChar; WPSLog: PWPSLog): HResult; stdcall;
    function WebPageSnapshot_CreateSnapshotThumbnailHandle(DataFolder: PChar; Width: Integer; Height: Integer; ThumbnailWidth: Integer; ThumbnailHeight: Integer; URL: PChar; var BitmapHandle: HBitmap; WPSLog: PWPSLog): HResult; stdcall;
The direct DLL functions work the same way as the COM class functions written above.

Set 'WPSLog' to 'nil' if not needed. But when used 'TWPSLog.LastErrorMessage' must be freed by the caller with CoTaskMemFree().


[Top]