A small script to generates ascii content for print receipts
create instance with page width
let page = new PeriPage(38);
add one line of text
page.addText([ { content: 'Ash Ketchum International Restaurant'.toUpperCase(), align: PeriPosition.center } ]);
adding a full width horizontal line
page.addHorizontalLine();
adding multiple cells in one line to make a table. the width is in percentage when not given it will adjust equal cell width
page.addText([ { content: 'qty'.toUpperCase(), align: PeriPosition.left, width: 10 }, { content: 'Item'.toUpperCase(), align: PeriPosition.left, width: 70 }, { content: 'Amount'.toUpperCase(), align: PeriPosition.right }, ]);
get rendered output
let output = page.output();
Please find the demo.js file for pre for the receipt generated on the right.
thank you.