PrintHtml icon indicating copy to clipboard operation
PrintHtml copied to clipboard

Possible to print rendered HTML of local .html files?

Open Jimadine opened this issue 4 months ago • 2 comments

I've been testing PrintHtml and have found that when printing HTML files that are stored locally on the filesystem, either by referencing them with file:/// or C:\path.., the raw HTML is printed rather than the rendered HTML. Is this a known issue? I can't think of any workarounds other than running a local web server and fetching the documents with http://localhost/.... In my particular use-case, the HTML is supplied by the return of a REST API, which is saved locally to a file before printing.

Also, and I don't think it's related since it occurs even when printing a remote HTML doc too, but I've noticed that after printing there's a sizeable (hundreds MBs) PrintHtml.exe.*.dmp file in %USERPROFILE%\AppData\Local\CrashDumps. Example command line: PrintHtml.exe -p "Microsoft Print to PDF" -a "80,297" https://www.york.ac.uk/teaching/cws/wws/webpage1.html.

Thanks in advance.

Jimadine avatar Oct 03 '25 14:10 Jimadine

Interesting, I have never tried to print from a file but I am not sure why it would not work? It just uses the Qt Html rendering engine internally via the Qt browser, so if it can render it from the web it should work for a file URL?

I have not checked for crash dump files on our system so not sure what to think of that. I have not done any development on this in a while and don't currently have Qt installed to debug it. Are you able to build it and debug it to see where it might be going wrong?

kendallb avatar Oct 03 '25 18:10 kendallb

Thanks for the reply. I just tried printing a local HTML file to a real printer (rather than a PDF printer) and the same thing happened — the raw HTML is printed. I'm unsure why it would do this — maybe a security measure by the Qt browser in that local files aren't trusted, but I have no hard evidence for this. Printing from http or https URLs delivers the expected behaviour — rendered HTML is printed.

Unfortunately I have very limited expertise in building/debugging to try and bottom out the crash dumps that are generated on my system.

Jimadine avatar Oct 06 '25 10:10 Jimadine