#1152408 printer-driver-foo2zjs: foo2qpdl -z2/-z3 sends a too short last stripe

Package:
printer-driver-foo2zjs
Source:
printer-driver-foo2zjs
Description:
printer driver for ZjStream-based printers
Submitter:
Pelle van der Heide
Date:
2026-10-28 20:31:01 UTC
Severity:
normal
Tags:
#1152408#5
Date:
2026-10-28 20:29:58 UTC
From:
To:
foo2qpdl's write_page_banded() (used for -z2 and -z3: CLP-310/315/325/
610, CLX-3175, CLP-620/360/365) labels every stripe record 128 rows
high and sends the JBIG BIH only once, for the first stripe. The last
stripe is encoded with only the rows that are left, so whenever the
clipped page height is not a multiple of 128 the printer decodes past
the end of that stripe's data.

With the default A4 clip (-u 150x100 -l 150x100, 7016 - 200 = 6816 rows
= 53 stripes + 32 rows), qpdldecode on foo2qpdl's output shows 54
stripes of H=128 for 6816 rows. On a Samsung Xpress C410W (driven as a
CLP-365, -z3) this prints a black bar below the page content. Letter (6400 rows) is a multiple of 128, which is
probably why it went unnoticed.

qpdldecode -d itself decodes the missing 96 rows of the last stripe
as ink in all four planes (723k dots in the K plane on a test page).

To reproduce without a printer:

  foo2qpdl-wrapper -z3 -c -C10 -Gsamclp315-argyll-0.icm -r1200x600 -p2 \
      some-a4-page.ps > out.qpdl
  qpdldecode < out.qpdl | grep -c 'stripe='   # 216: 54 per plane, all H=128
  qpdldecode -d out < out.qpdl                # out-01-*.pbm: rows 6816+ inked

The attached patch pads the last stripe with blank rows and always
encodes 128 rows, so every row that printed before is unchanged.
Tested on the C410W: the black bar is gone, and rows 0-6815 decode
identically before and after.