kendallb / PrintHtml

Open source command line program to print HTML pages using QtWebKit
MIT License
50 stars 19 forks source link

Exitcode #21

Open lazna opened 2 years ago

lazna commented 2 years ago

Does this prohgram provide any exitcode (errorlevel) if sending to printer (or printing itself) failed?

Found nothing in documentaion

kendallb commented 2 years ago

Not sure if the WebKit print function has a return value to indicate failure but the code currently does not return a failure if it somehow failed to print. It will return an error if the URL fails, but not if printing failed.

Most print routines usually don’t fail as it gets spooled to the print queue and if the printer is not working it is stuck in there until you fix it. So the app doing the printing assumes it all works once it gets spooled.

lazna commented 2 years ago

OK, but what about the program itself? If wrong (insuficient) parameter provided for example? Does it only print error message or set exitcode too? Need distinguis between situations:

"data was successfully sent to printer\queue"

and

"any problem occurs"

kendallb commented 2 years ago

Yes, starting here you can see the error handling. Would not be hard to update it to add more error handling if you needed more fine grained details. I just am not sure if you can tell if the printing actually failed at all.

https://github.com/kendallb/PrintHtml/blob/master/main.cpp#L103

lazna commented 2 years ago

Unable to read C code, unfortunatelly :-/

lazna commented 2 years ago

Just found, when there is a typo in path to HTML file to be printed, GUI message "Fatal error: HTML page failed to load" is displayed. In console programs, opening GUI boxes should be generaly avoided. Print ERRMSG to STDERR and set errorlevel instead, please

kendallb commented 2 years ago

Unfortunately this program is not a console program, as it needs access to Windows UI components in order to print.

lazna commented 2 years ago

thanks. This is a very important information and should be mented in the beginning of documentation. The list of switches in documentation look like console program and could mislead people.

Is there a chance to run it by psexec by -i or -x switches?

-i Run the program so that it interacts with the desktop of the specified session on the remote system. If no session is specified the process runs in the console session. -x Display the UI on the Winlogon secure desktop (local system only).

cant test it now