#!/bin/bash # # Generates a page-break diagnostic file: numbered lines padded with '#' to # a fixed width, so you can see exactly where a printer's real page length # and line width limits are instead of guessing from paper geometry. # # Usage: ./pagetest.sh [width] [lines] # width - characters per line, including the "NNN " prefix (default 64) # lines - number of lines to generate (default 100) # # Print the result with PRINTER_A4=false in printer.conf (no rotation), so # the line numbers read straight off the page: # ./txt2printr.sh pagetest.txt dir="$(dirname "$0")" width="${1:-64}" lines="${2:-100}" outfile="$dir/pagetest.txt" awk -v width="$width" -v lines="$lines" ' BEGIN { for (i = 1; i <= lines; i++) { prefix = sprintf("%03d ", i) fill = width - length(prefix) if (fill < 0) fill = 0 line = prefix for (j = 0; j < fill; j++) line = line "#" print line } } ' > "$outfile" echo "Wrote $lines lines x $width chars to $outfile" echo "Print it with: PRINTER_DEV=/dev/lp0 \"$dir/txt2printr.sh\" \"$outfile\""