question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sending commands to printer through Cloud Print

See original GitHub issue

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

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.

sample

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:open
  • Created 3 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
receiptlinecommented, Mar 6, 2021

Hello! Thank you for using receiptline. Please try the following.

  • Set command to match the memory switch setting of mC-Print3

    // command: 'starmbcs'
    command: 'starsbcs'
    
  • Change the character encoding of express from utf-8 to binary

    // return receiptline.transform(doc, printer);
    return Buffer.from(receiptline.transform(doc, printer), 'binary');
    
1reaction
receiptlinecommented, Mar 7, 2021

I think startups tend to print in graphics, but POS systems traditionally print in device fonts for the following reasons

  • Faster printing speed
  • Works well with legacy serial connections
  • Clear characters suitable for business use

As for character visibility, the printing quality of thermal paper is low, so graphics may cause misreading of characters.

  • 1, I or l
  • 0 or O
  • e or c

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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Setup and Print Wirelessly With Google Cloud Print
To start printing from your Chrome, Ctrl+P the command or select 'Print' from the wrench menu. A new Window or 'Tab' will appear...
Read more >
Configure Cloud Print for Mobility Print
You'll see the Cloud Print section in the central panel. Screenshot showing configuration options in Mobility Print's admin interface. ... Click Enable Cloud ......
Read more >
How to print using Google Cloud Print and Print Node ...
In order to use Google Cloud Print for printing purpose, you need to first set up ... an automatic command will be sent...
Read more >
Cloud Print
Any web-connected device can use Google Cloud Print. Share & manage printers. Manage your printers and printing jobs, and share printers securely from...
Read more >
How to print from an Android phone or tablet
With Google Cloud Print, you can send items to your printer from your Android phone. ... You'll find the Print command in Google...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found