Home / Alt manpages / pbmpage(1)

  • pbmpage(1)
  • User command
  • linux

Generate Netpbm Printer Test Pages with pbmpage

You will create a PBM test page that exposes printer resolution, margins and paper handling. The examples use the Netpbm package installed on this machine, version 2:11.05.02-1.1build1. Allow about five minutes if Netpbm is already installed. The command does not need root privileges, and it writes the image to standard output, so redirect it to a file before doing anything with a printer.

Checkpoint: confirm the command and package

First check that the executable and package are present:

command -v pbmpage
dpkg-query -W -f='\${Package} \${Version}\n' netpbm

Expected output includes /usr/bin/pbmpage and a package line beginning with netpbm 2:11.05.02-1.1build1. The exact package revision can differ on another system. The installed manual describes the program as producing a one-page PBM pattern intended for a 600 dots-per-inch printer.

Choose a test pattern

pbmpage accepts a pattern number. Pattern 1 is the useful first check: it is a numbered grid with a one-pixel box at the paper edges. Pattern 2 is a one-pixel-wide vertical line rising half an inch from the exact centre. Pattern 3 draws two diagonal lines, one from each opposing corner, towards the centre.

The manual gives 1 as the default, and this installed build also accepts an invocation with no pattern argument. Supplying the number is clearer in a script and avoids relying on that default:

pbmpage 1 > printer-test-us.pbm

There is no terminal preview because the file is binary PBM data. A successful command normally prints nothing and returns exit status zero. Check the file before sending it anywhere:

file printer-test-us.pbm
pamfile printer-test-us.pbm

For the default US paper size, the installed command reports PBM raw, 5100 by 6600. That is 8.5 by 11 inches at 600 dpi. If pamfile is unavailable, file should still identify it as Netpbm image data and show the same dimensions.

Checkpoint: use A4 deliberately

Without an option, pbmpage generates a US standard 8.5 by 11 inch page. Use -a4 for European A4 paper:

pbmpage -a4 1 > printer-test-a4.pbm
pamfile printer-test-a4.pbm

On this installation the A4 file is PBM raw, 4960 by 7016, which matches 8.2667 by 11.6933 inches at 600 dpi. The option changes the generated image dimensions; it does not configure the printer's paper tray. Set the printer or print queue to A4 as well, or the driver may scale, crop or reject the page.

Run the other patterns when diagnosing alignment

Use patterns 2 and 3 when a grid is not enough to reveal a problem:

pbmpage 2 > printer-test-centre.pbm
pbmpage 3 > printer-test-diagonals.pbm
pamfile printer-test-centre.pbm printer-test-diagonals.pbm

Both files use the selected US dimensions unless you add -a4. Pattern 2 helps expose a shifted centre or an uneven vertical feed. Pattern 3 makes skew and unequal margins easier to see. These are diagnostic images, not calibration data for a particular printer model.

Send the PBM through the printing path

Do not assume that a correct PBM proves the printer itself is correct. The manual warns that the printer driver and any image converter can adjust margins, crop edges or erase pixels. The test therefore covers the whole path from this file to the paper.

Use the printing command appropriate to your system and inspect its options first. For example, with a CUPS queue named Office_Printer:

lp -d Office_Printer printer-test-us.pbm

The queue name is a placeholder, and the available PBM filters are system-specific. Check the command's result and the printer queue before treating the page as a valid test. If you use an HP PPA printer, the manual identifies pbmtoppa as the Netpbm converter for turning this output into a printer stream. Check that converter's own manual before sending data.

Recover from a page that is too large

If the printer or driver rejects the image because margins leave too little printable area, do not edit the original test file. Make a separate cropped copy with pamcut, removing pixels from the right and bottom edges until it fits:

pamcut -cropright 500 -cropbottom 500 printer-test-us.pbm > printer-test-cropped.pbm
pamfile printer-test-cropped.pbm

The numbers above are an example crop, not a universal setting. The pamcut syntax and edge interpretation belong to that command, so consult pamcut(1) for the exact crop you need. Cropping discards part of the diagnostic image; the original remains unchanged and can be regenerated at any time with pbmpage 1.

Common traps

  • Do not type pbmpage 1 into a terminal and expect readable text. Redirect standard output to a file.
  • Do not confuse the -a4 image with a printer setting. Select A4 in the queue or driver too.
  • Only patterns 1, 2 and 3 are recognised. An invalid number exits with status 1 and reports the error on standard error.
  • Do not use a cropped file as proof that the original page fits. Keep both files and record which one was printed.

Done means

  • pbmpage is installed and its package version is known.
  • A pattern file passes file or pamfile as a PBM image with expected dimensions.
  • The image paper size matches the physical paper and the printer queue setting.
  • You know whether a margin problem came from the image, driver, converter or printer.