Sending commands to printer through Cloud Print
See original GitHub issueHi,
First - Thank you San for your work and sharing. This is very helpful.
We are using Star - MC3 printer and using its CloudPrint facility to send print through the REST API server as we need to print directly on the printer without any intermediate device. After looking through your markup language, I am reluctant to use Star proprietary markup language. We would like to follow a standard, that you are developing.
I ran your sample code and it works fine if I send the print commands directly to my printer in the local subnet using its IP address and port 9100. The prints are as advertised and seen through the designer - which is really very useful to visualize.
But, when I send the same command through the REST API through our API server to the printer, everything prints OK except the line.
Here is the sample code:
printCommands.js file
var doc = `
{width:auto}
|^^^^Pizza Station^^^^|
-
{width:5 *}
|^^2 @^^ |^^Royal Special Pizza |
| |Olive, Spinach, Asparagus, Tomato |
|^^1 @^^ |^^12 inch Subway with basil |
-
-
{width:auto}
Delivery Station
{width:5 *}
|2 @|French Fries |
|1 @|Diet Coke |
-
{code:2012345678903;option:ean,hri}
`;
...
async function ticket() {
// printer example
const printer = {
cpl: 42,
encoding: 'cp437',
upsideDown: false,
gamma: 1.8,
command: 'starmbcs'
};
return receiptline.transform(doc, printer); ;
}
...
The above is called in the REST API GET request sent by the printer to my API server.
var printer = require("./printCommands");
app.get('/api/v1/cloudprint', (req, res) => {
printer.ticket().then((buffer) => {
res.status(200).type("application/vnd.star.starprnt").send(buffer);
toPrint = false;
}).catch((err) => {
console.log("Getting error in sending commands to the printer", err);
res.status(200).end();
});
}
I have tried starsbcs
and various supported input methods from Star Link but I was not able to get the line printing properly.
I am attaching here both the prints - one sent directly to the printer (works perfectly) and another sent through REST API using CloudPrint of Star Printer.
Can you please provide tips or hacks for the time being so that I am able to print it correctly?
Thank-You San!
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (6 by maintainers)
Top GitHub Comments
Hello! Thank you for using receiptline. Please try the following.
Set command to match the memory switch setting of mC-Print3
Change the character encoding of express from utf-8 to binary
I think startups tend to print in graphics, but POS systems traditionally print in device fonts for the following reasons
As for character visibility, the printing quality of thermal paper is low, so graphics may cause misreading of characters.
1
,I
orl
0
orO
e
orc
The SVG created by receiptline uses a web font called Courier Prime. The visibility of the font is good, but please consider whether it meets the requirements of your system.
By the way, I would like to introduce convert-svg-to-png to some people who just want to print SVG receipt images.
Thank you!