On Thursday, 8 December 2022 17:19:49 GMT G. Branden Robinson wrote: > Hi Wim, > > At 2022-12-08T15:51:07+0100, Wim Stockman wrote: > > I am making a simple cash register with a ticket printer. and I want > > to figure out how I can detect how long my physical paper should be > > without cutting some text off. So I can set it for the device. The > > width is fixed so that is no issue. Eventually I can run it in some > > loop and detect when it stops having more than one page. > > I reckon I would have a couple of macros that open and close a > diversion, then measure against an argument that specifies the limit > imposed by the hardware (i.e., length of paper roll remaining). > > Here's a conceptual sketch. > > .de StartTicket > . br > . di Ticket > .. > . > .de EndTicket > . di > .. > . > .while 1 \{\ > . StartTicket > .\" input for ticket text goes here > . EndTicket > . if (\n[dn] > \n[ticket-printer-paper-length]) \ > . ab ticket too long for remaining paper; aborting > .\} > > Please clarify if I've overlooked a requirement. > > Regards, > Branden
I'm probably missing something here, but ticket printers are normally continuous rolls with a cutter, so isn't this a problem of controlling the cutter rather than specifying a media size. There is usually a printer option to cut after each print job, so if you make each receipt a separate print job, it should do the cutting for you. Just give groff a sufficiently long page length for the longest ticket you expect. I have a Brother thermal printer which I use for labels, but it will take a continuous role instead, and I believe it has a proprietary EscP command for controlling the cutting, so there may be a solution using something similar. Cheers Deri