vaginessa / ricoh-sp112-ppd

5 stars 3 forks source link

Printing from MacOS does not work #2

Open cfstras opened 1 year ago

cfstras commented 1 year ago

I've noticed that printing with this does not work from macOS.

After fiddling way too long with the sync/async variant (the error handling and trapINT in the async variant makes debugging hard), I noticed the reason is pretty simple:

The first CUPS filter in a printing filter chain gets input in $6, everybody else gets input from stdin. It seems that macOS print jobs (printing from Preview.app in a PDF) don't require any additional CUPS filter, so our driver is not getting input from stdin, instead, a new parameter #6 appears. (source)

Here's my fix:

inputfile="$6"
if [[ $inputfile == "" ]]; then
    inputfile='-'
fi 

https://github.com/cfstras/ricoh-sp112-ppd/blob/0ef194485b9398aa0a8291be7c29a36bed7cb2cb/pstoricohddst-gdi#L39-L42

    log "eating input"
    cat "$inputfile" > $uid/input.gs
    # Converting from PostScript to PostScript-monochrome, then to PBM image format (per page)
    log "Converting document to pages"
    gs -sDEVICE=ps2write -sOutputFile=- -r$resolution -dQUIET -dBATCH -dNOPAUSE "$uid/input.gs" | gs -sDEVICE=pbmraw -sOutputFile=${uid}/%03d-page.pbm -r$resolution -dQUIET -dBATCH -dNOPAUSE -

https://github.com/cfstras/ricoh-sp112-ppd/blob/0ef194485b9398aa0a8291be7c29a36bed7cb2cb/pstoricohddst-gdi#L167-L171

(eating the input to the $uid temp dir is only done for debugging convenience, not necessary.

lukpe commented 9 months ago

Hi @cfstras,

I still can't print on MacOS. Any additional steps are needed? What I did was: Run check-requirements

pbmtojbg     [REQUIRED] : Yes, version: PBMtoJBIG converter 2.1 -- creates bi-level image entity (BIE) as output file
identify     [REQUIRED] : Yes, version: Version: ImageMagick 7.1.1-21 Q16-HDRI aarch64 21667 https://imagemagick.org
Ghostscript  [REQUIRED] : Yes, version: 10.02.1
ps2write     [REQUIRED] : Yes
pbmraw       [REQUIRED] : Yes
inotify-wait [optional] : No

Replace pstoricohddst-gdi with your code Copy it to /usr/libexec/cups/filter sudo chown root pstoricohddst-gdi sudo chmod +x pstoricohddst-gdi Add printer using RICOH_Aficio_SP_112.ppd

Description: | RICOH SP 112 DDST
-- | --
Ricoh Aficio SP 112, pstoricohddst-gdi 0.5 alpha (grayscale)
usb://RICOH/SP%20112%20DDST?serial=X025M930995
job-sheets=none, none media=iso_a4_210x297mm sides=one-sided

Any suggestions?

cfstras commented 9 months ago

Check the start of the file - you can enable logging there. Then, you should check your cups logs while trying to print. Either journalctl or /var/logs/cups…

Sadly the setup is pretty brittle, there’s a ton of things that can go wrong. I‘m sorry to say this but I‘d recommend getting another printer that supports a modern standard (such as AirPrint)