Dynamic paper length

Last-Updated: 2023-05-17

Sources

Goal of the program

The Receipt Maker program (wimstockman/receipt_demo) was written by Wim Stockman to print receipts typeset with groff. However he was met with an issue: not knowing the paper length needed to print a receipt before typesetting it, while also needing to give this information to groff to typeset said receipt.

Solution implemented by Wim Stockman

His solution uses three steps:

This is achieved by outputting the vertical position reached at the end of the receipt to standard error with the following code (in the file receipt.tmac):

.tm \\n[nl]

This information is collected on the first pass (by only printing error messages with groff -z) and fed to groff on the second pass (in the file printreceipt.sh).

← Go back