-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sending commands to printer through Cloud Print #4
Comments
Hello!
|
Thank YOU, San! It worked perfectly. I realize that it is mentioned in the document somewhere but I did not realize it until you told me. However, I also tried the other way as an alternative where I used This is what I also did with SVG and then the REST API server.
REST API Server.
I am now a little confused about which approach - I should take. Also, I am going to adopt your standard for receipt printing and am thinking to write some handlebars that can take care of emitting the markup syntax using an input JSON. Thank again - I wish that all major printer manufacturers adopt this as a standard. I like Star printers and they are very nice in support but your markup language is far better especially the designer. |
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.
The SVG created by receiptline uses a web font called Courier Prime. 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! |
Thank YOU, San! I am running into another issue. Our customer has several Epson TM-220 impact printers. I understand that these printers are as old as 2004 and they are still being used. I tried Following your node.js example, I tried the following code.
It prints but with some extra chars. Your README says that the The printed receipt is as per the picture attached. I very much appreciate your guidance. |
Thanks again for using receiptline. |
Thank YOU so much. This will be very useful and I really appreciate your help. If you support TM-U220 impact printers, you can remove all those features that are not necessary like code, QR Code, images, etc, and the support for USB, etc. The only requirements will be Ethernet and at most serial cables. The markup that is only supported on Thermal printers can be safely ignored and not printed. For example, safely ignore images, etc. If I could use the same markup, it will make life much easier. I am using handlebars helper functions to abstract the formatting so that the code works seamlessly for Thermal printers and future TM-220 impact printers. For example: Here is the sample code.
The sample template
The buffer - I can feed to the REST API GET request from Star or other cloud-enabled printer or just feed to the IP address:9100 for local or remote printing. This makes life much easier to maintain the code for multiple printers, local or cloud printing. The only thing that I will request is to allow a color change of the ribbon and the double-width and double-height chars for impact printers. I will be more than happy to do tests for you and give any testing feedback. I am looking forward for this. |
Thank you for waiting.
// TM-U220 Font A
const printer = {
"host": "192.168.1.170",
"port": 9100,
"cpl": 33,
"spacing": true,
"command": "impact"
}; // TM-U220 Font B
const printer = {
"host": "192.168.1.170",
"port": 9100,
"cpl": 40,
"spacing": true,
"command": "impactb"
}; |
@receiptline - Thank you San!. I tested and it worked like a charm. I sincerely appreciate it. Thank you again. Can I send you StarBucks coffee gift card to your email account for your prompt service as a token of appreciation? Please share your email address. |
Thank you as well. |
I'm currently evaluating My aim is to get it to work with Star Now I'm facing something similar when trying to send the receiptline-document as "raw" data using Epsons XML approach. My suspicion it's caused by poor encoding, or that I don't get if I have to trim something off (like initialization instructions in the linked answer), or both. Basically, when I'm doing is (psudo-coded) something like: const document = transform(content, {
encoding: 'multilingual',
...
command: commands.escpos
});
const bin = Buffer.from(document, 'binary');
const instructions =
`<epos-print xmlns="http://www.epson-pos.com/schemas/2011/03/epos-print">
<command>${bin}</command
</epos-print>`;
return `<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body>
${encodeEscapeSequence(instructions)}
</s:Body></s:Envelope>`; and POST it to a TM-i-series printer. Any variation I have tried, I get a "SchemaError", e.g. <?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" >
<soapenv:Body>
<response success="false" code="SchemaError" status="0" battery="0" xmlns="http://www.epson-pos.com/schemas/2011/03/epos-print"/>
</soapenv:Body></soapenv:Envelope> Any ideas or inputs would be highly appreciated! |
Hello! I have created the following code based on an example using Epson Server Direct Print. const http = require('http');
const receiptline = require('receiptline');
const printer = {
cpl: 42,
encoding: 'multilingual',
spacing: true,
command: 'escpos'
};
const order = `{width:*}
^^^Online Order
${new Date().toLocaleString('en')}
{width:4,*}
---
|^^^2|^^Hamburger
| |Tomato, Onion, Meat sauce, Mayonnaise
| |\`"~Mustard~
|^^^2|^^Clam chowder
| |Oyster cracker
---
{code:1234567890; option:code128,2,72,hri}`;
let jobid = 1;
const command = receiptline.transform(order, printer);
// remove ESC @ (initialize printer) GS a 0 (disable automatic status back)
const hex = Buffer.from(command, 'binary').toString('hex', 5);
const xml = `<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<parameter xmlns="http://www.epson-pos.com/schemas/2011/03/eposprint">
<devid>local_printer</devid>
<timeout>60000</timeout>
<printjobid>${jobid++}</printjobid>
</parameter>
</s:Header>
<s:Body>
<epos-print xmlns="http://www.epson-pos.com/schemas/2011/03/epos-print">
<command>${hex}</command>
</epos-print>
</s:Body>
</s:Envelope>`;
const options = {
host: '192.168.192.168',
port: 80,
path: '/cgi-bin/epos/service.cgi',
method: 'POST',
headers: {
'Content-Type': 'text/xml; charset=utf-8',
'Content-Length': Buffer.byteLength(xml)
}
};
const req = http.request(options, res => {
console.log(`${res.statusCode} ${res.statusMessage}`);
res.on('data', chunk => {
console.log(chunk.toString());
});
});
req.on('error', err => {
console.log(err.message);
});
req.end(xml); It worked on TM-T88VI. Thank you! |
By tweaking some parts with the help of what you wrote above, I finally got it to work now. |
I have a similar question/issue to the one above. We are printing to the Epson TM printers from a web app using the Epson ePOS SDK for Javascript (version 2.27.0). How would I use receiptline with the SDK? |
Hello! Please use Receipt.js instead of receiptline. <script type="text/javascript" src="receipt.js"></script>
<script type="text/javascript" src="receipt-printer.js"></script>
<script type="text/javascript" src="qrcode-generator/qrcode.js"></script> const markdown = `^^^RECEIPT
03/18/2024, 12:34:56 PM
Asparagus | 1| 1.00
Broccoli | 2| 2.00
Carrot | 3| 3.00
---
^TOTAL | ^6.00`;
const receipt = Receipt.from(markdown, '-p epson -c 42');
const command = await receipt.toCommand(); Thanks! |
Hi,
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
The above is called in the REST API GET request sent by the printer to my API server.
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!
The text was updated successfully, but these errors were encountered: