CXP print ticket

This forum is for conversations about Internet development using CXP, WebSockets, HttpEndPoint, etc.
Post Reply
Message
Author
User avatar
PedroAlex
Posts: 235
Joined: Tue Feb 09, 2010 3:06 am

CXP print ticket

#1 Post by PedroAlex »

Hi,

I made a small application in CXP based on the "orders" sample to make online orders.
The application works well on Android smartphones.
But I need to print a small receipt on an 80-column thermal roll paper printer connected via BT. But it's not easy.
Does anyone have this type of solution working, who can give a tip or a small sample?
Printing directly to a printer in CXP is not easy!!
Thanks.
Pedro Alexandre

User avatar
Tom
Posts: 1230
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: CXP print ticket

#2 Post by Tom »

Client-side-printing in a web application is mostly realized using Javascript. This is a sample code that prints any html-content ('el'). ChatGPT can help you with that kind of issues. Embedding Javascript in a CXP application should be easy (but I don't use it).

Code: Select all

function printContent(el) {
    var restorePage = document.body.innerHTML;
    var printContent = document.getElementById(el).innerHTML;
    document.body.innerHTML = printContent;
    window.print();
    document.body.innerHTML = restorePage;
}
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
PedroAlex
Posts: 235
Joined: Tue Feb 09, 2010 3:06 am

Re: CXP print ticket

#3 Post by PedroAlex »

Hello Tom.
Thank you for your quick response.
I have already tried this type of printing.
It is not practical and does not work well...
What I need is a way to print the contents of an array on a 40-column form without having to constantly select the driver. You know that on Android the printer is connected via Bluetooth and the printing system is somewhat different.
What I am looking for is something different. I am investigating the possibility of printing directly to the port or something like that. Here, the applications that work in the cloud use an application installed on the smartphone that receives the packages from the website and proceeds to print.
I think that is the direction I should go, but I don't think I can do it with the CXP!!
I was hoping that someone here on this forum had some experience in this area!!

Thank you very much Tom!!
Pedro Alexandre

Post Reply