receiptio
receiptio copied to clipboard
Left margin option
Hi,
In the industry I work on it is very common that ticket paper has a color brand stripe to the left side:
In order for the text not be placed over the stripe, some precautions should be taken.
My solution is to add a "margin" parameter ("-m") to receiptio, and then overwrite the "area" command accordingly:
const transform = async (receiptmd, printer) => {
// ...
// ...
if (printer.leftMargin) {
printer.command = Object.assign(
{},
typeof printer.command === 'object' ? printer.command : receiptline.commands[printer.command]
);
// overwrite area function
const a = printer.command.area;
printer.command.area = (left, width, right) => a(left + printer.leftMargin, width, right - printer.leftMargin);
}
return receiptline.transform(receiptmd, printer);
};
Also, the parameter cpl
might need to be adjusted.
i.e. with a cpl
of 48 and a leftMargin
of 2, will give a total width of 50, forcing the wrapping of every line.
So, when cpl
is not manually provided it should be adjusted:
cpl = default - leftMargin
I'm unsure this should be part of the receiptline or the receiptio tool. My implementation is on receiptio, but it might also fit as a general parameter in receiptline. It could also be extended to right margin, of course.
Regards,