A first v0.1 preview of cefHtmlSnapshot is now available at https://github.com/EricGrange/cefHtmlSnapshot.
This is a command-line utility that aims to take image (PNG, JPG) or PDF snapshots of an HTML website or file, and fill in the “void” left by the abandon of Qt webkit tools like phantomjs or wkhtml2pdf. While those old utilities still work, they do not support modern web standards, and any tidbit of ECMA6 will have them stumble.
Precompiled binary is available at https://github.com/EricGrange/cefHtmlSnapshot/releases/tag/v0.1
This project is uses the Chromium Embedded Framework, and leverages the excellent work of Salvador Díaz Fau with CEF4Delphi.
My first use case will be the preview snapshots in https://www.beginend.net/, hence it comes with the ability to inject Javascript before taking a snapshot and sample script dedicated to busting EU Cookie Law banners.
While there is a bunch of arguments supported, basic usage is intended to be straightforward. You can take a snapshot of this site with
cefHtmlSnapshot https://delphitools.info/ --javascript Scripts\cookie-law-buster.js snapshot.jpg
and if you want a PDF version
cefHtmlSnapshot https://delphitools.info/ snapshot.pdf
For reference the supported arguments as of v0.1 are
cefHtmlSnapshot.exe url_or_file [-arg1 value1] [-arg2 value2] ... output_file -?, -h, --help This inline documentation url_or_file URL of the website or file to be snapshotted (required) output_file Output file pathname, extension determines format (default snapshot.bmp) -w, --width Width of the snapshot, between 1 and 2048 (default 1024) -h, --height Height of the snapshot, between 1 and 2048 (default 768) When output format is a PDF, this parameter is ignored -d, --delay Delay in milliseconds, between 100 ms and 30 sec (default 1 sec) -s, --scale Scale of the website relative to 96dpi, between 0.1 and 10.0 (default 1.0) --quality Output JPEG quality (1 to 100, default 90) --compression Output PNG compresson level (0 to 9, default 7) --cookie set a cookie, format is CommaText, starting with name=value, then fields url= cookie url (uses scheme + domain from url parameter by default) domain= cookie domain (uses domain from url parameter by default) path= cookie path ("/" by default) secure= secure flag (0 or 1, by default 1 if url starts with "https:") httponly= htpOnly flag (0 or 1, by default 0) --javascript Name of a JavaScript file to execute just before taking the snapshot --pdf-xxx PDF output options outlined below page-width page width in microns (default 210000) page-height page height in microns (default 297000) margins sets all margins in points margin-top top margin in points (default 20) margin-left left margin in points (default 20) margin-right right margin in points (default 20) margin-bottom bottom margin in points (default 20) landscape portait (default, 0) or landscape (1) backgrounds enable backgrounds (1) or not (default, 0)