Open yasirhantoush opened 3 years ago
Not sure why it takes so long for you, as it does not take that long for us. Maybe depends on the speed of the computer it is running on? Is it getting the HTML from the internet? Maybe it's slow getting the HTML?
If the issue is the time taken for the program to start running, then yeah, a web service would help. If it's the time to get the data over the internet, you would need to speed that up first.
I am using it with direct file:
PRINTHTML printername=cash1 file=receipt.html
But in my scenario I am printing 2 or 3 work orders in row.
This is the best solution I could find until now. May be we could explore running the tool in a web service mode. I would love to help on this.
Br Yasir
This might be a good starting point for creating small web server found on this https://github.com/qt-labs/qthttpserver/blob/master/examples/httpserver/afterrequest/main.cpp
#include <QtCore>
#include <QtHttpServer>
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
QHttpServer httpServer;
httpServer.route("/", []() {
return "Hello world";
});
httpServer.afterRequest([](QHttpServerResponse &&resp) {
resp.setHeader("Server", "Super server!");
return std::move(resp);
});
const auto port = httpServer.listen(QHostAddress::Any);
if (!port) {
qDebug() << QCoreApplication::translate(
"QHttpServerExample", "Server failed to listen on a port.");
return 0;
}
qDebug() << QCoreApplication::translate(
"QHttpServerExample", "Running on http://127.0.0.1:%1/ (Press CTRL+C to quit)").arg(port);
return app.exec();
}
I am thinking we can make a new executable like printhtmld (d for deamon mode), we can make it configurable to listen on specific PORT/ IP ADDRESS
We can define a route like this
We can define a json object to have properties representing the args like this:
{
"html": "<h1>Hello World</h1>",
"printerName": "0",
"title": "The world",
"footer": "0",
"header": "",
"topMargin": "0",
"bottomMargin": "0",
"rightMargin": "0",
"leftMargin": "0",
"secret" : "ASFaw4fa$FAdfasGA#$%garAGHSHTseh53ayEHsdfshfsdfSGFSdgear"
}
Not sure it's necessary for a separate application, just add a -d parameter or something to have it sit there and listen for requests. I think it would be useful for a lot of folks.
I have not built this in a long time (I don't have the Qt stuff installed at the moment) but porting it to run with the latest Qt to pick up bug fixes in the HTML rendering engine would be a good idea also. I believe it can work with the latest Qt now (it was stuck on 4.8 due to QtWebKit being dropped).
I am using it for a restaurant for printing on the thermal receipt printer. However it has a delay around 4 to 5 seconds each time it gets executed. Any ideas how to improve this ? Maybe if we converted it to QT web service or QT windows service could be much faster?