Fix HP LaserJet 1018 raster scaling on Apple Silicon macOS - #1
Open
greenflute wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix severely undersized output from the HP LaserJet 1018 when using the native ARM64
rastertozjsCUPS filter on Apple Silicon macOS.This change adds an ARM64-specific PPD that correctly configures the raster resolution. It also adds controlled diagnostic logging and an optional way to capture the generated ZjStream without changing the
data written to CUPS stdout.
Tested environment
usb://Hewlett-Packard/HP%20LaserJet%201018?serial=KP3DDRPrastertozjssihp1018.imgconverted witharm2hpdland uploaded before printingSymptoms
The native ARM64
rastertozjsfilter compiled and executed successfully. CUPS completed the print job, and the printer accepted data and fed paper.However, the printed content occupied only a very small area of the page and appeared almost blank.
Explicitly selecting A4 and requesting 600x600 dpi did not initially resolve the problem.
Root cause
The ARM64 PPD was derived from the original Foomatic PPD. Its resolution choices still contained Foomatic-only comments:
The ARM64 printing pipeline bypasses
foomatic-rip:Because
cgpdftorasterdoes not interpret the Foomatic comments as PostScript resolution settings, it generated a 100x100 dpi CUPS raster even when 600x600 dpi was requested.The issue was reproduced offline. Before the fix, an A4 page requested at 600x600 dpi produced:
The filter then generated a ZjStream page header containing:
The raster contained approximately 100 dpi worth of page pixels, while the printer was told to interpret the horizontal raster at 600 dpi. This caused the page content to be rendered at a fraction of its
intended physical size.
Fix
Add an ARM64-specific HP LaserJet 1018 PPD using the native CUPS raster filter:
Replace the Foomatic-only resolution comments with standard PostScript
setpagedeviceinstructions:After this change,
cgpdftorastercorrectly applies the selected resolution.ZjStream calculations
The following HP 1018/1020 calculations were compared with the original
foo2zjsMODEL_HP1020implementation:Although this behavior initially appeared suspicious, it matches the original upstream
foo2zjsimplementation.This PR therefore does not change the existing
VIDEO_X,RASTER_X,VIDEO_BPP, or HP 1018/1020 resolution calculations.Diagnostics
rastertozjsnow writes detailed per-page diagnostics using the prefix:The diagnostics include:
cupsWidthcupsHeightcupsBytesPerLinecupsBitsPerPixelcupsBitsPerColorcupsColorSpaceHWResolutionImagingBoundingBoxcupsImagingBBoxExisting CUPS logging is preserved.
Optional ZjStream capture
Setting the following environment variable saves an identical copy of the generated ZjStream:
The filter continues writing normally to stdout so that CUPS printing behavior is unchanged.
All binary output paths use shared output helpers to ensure that stdout and the optional debug file receive the same bytes.
The captured file and stdout output were verified with
cmpand SHA-256 and were byte-for-byte identical.No file is written unless
RASTERTOZJS_DEBUG_FILEis explicitly set.Offline verification
The following offline test path was successfully established:
Example raster generation:
cupsfilter \ -i application/pdf \ -m application/vnd.cups-raster \ -p PPD/HP-LaserJet_1018-arm64.ppd \ -o PageSize=A4 \ -o Resolution=600x600dpi \ testpage.pdf > /tmp/lj1018.rasterExample ZjStream generation:
600x600 dpi result
The 600x600 dpi path was validated both offline and on the physical HP LaserJet 1018.
After the PPD fix, the A4 CUPS raster reports:
The generated ZjStream reports:
The JBIG width is padded to the alignment required by the HP 1018/1020 path, while the logical raster and video widths remain correct.
The physical printer produced a correctly sized page at 600x600 dpi.
1200x600 dpi result
The 1200x600 dpi path was validated both offline and on the physical HP LaserJet 1018.
The A4 CUPS raster and generated ZjStream report:
These values match the expected upstream
MODEL_HP1020behavior.The physical printer produced a correctly sized page at 1200x600 dpi without horizontal compression, stretching, or other visible scaling errors.
Physical printer verification
The corrected output was verified on a physical HP LaserJet 1018 at both supported resolutions:
At both resolutions, the page printed at the expected physical size instead of being reduced to a very small area.
The tests were performed over USB on macOS Tahoe 26.x running natively on an Apple Silicon M5 Max without Rosetta.
Because the HP LaserJet 1018 stores its firmware in volatile memory, the firmware must be uploaded again after the printer is powered off or restarted. Firmware loading is separate from the raster-scaling fix
in this PR.
Build verification
The repository CI build path was reproduced locally:
All nine filters compiled successfully:
All generated filters were verified as:
The
rastertozjsdynamic dependencies remain limited to macOS system libraries:No Rosetta, x86_64-only libraries, Intel Homebrew libraries, or additional third-party dynamic dependencies are required.
PPD validation
The new PPD passes
cupstestppd.The remaining warnings concern pre-existing non-standard media names inherited from the original Foomatic PPD and are unrelated to this fix.
Scope
This change is intentionally limited to:
rastertozjsIt does not delete or modify existing HP drivers, CUPS queues, system security settings, SIP configuration, or firmware files.