Closed gavinmcc closed 2 years ago
or how I have configured the printer.
I went back and used this to make sure I was using the standard Macbook setup:
38f9d35c0f7b:remarkable_printer gavinmc$ sudo make install_config
Password:
lpadmin: Printer drivers are deprecated and will stop working in a future version of CUPS.
No change.
As an experiment, I added an extra PJL line to the start of a stock PDF file to make sure the Go code still does what we would expect, if the PJL is included in the payload:
38f9d35c0f7b:~ gavinmc$ head -5 Downloads/forgotten_side_dns_hacked.pdf
@PJL JOB NAME = "Document Title!" <LF>
%PDF-1.5
%????
6 0 obj
<<
38f9d35c0f7b:~ gavinmc$ nc 10.11.99.1 9100 < Downloads/forgotten_side_dns_hacked.pdf
38f9d35c0f7b:~ gavinmc$
Sure enough, we see it in the log and the file is titled "Document Title!" in the reMarkable UI.
Mar 28 05:09:42 reMarkable printer.arm[2209]: Saving PDF to: /home/root/.local/share/remarkable/xochitl/c94d476e-d51d-4bb3-837b-98cb6948ef21.pdf
Mar 28 05:09:42 reMarkable printer.arm[2209]: @PJL JOB NAME = "Document Title!" <LF>
Mar 28 05:09:42 reMarkable printer.arm[2209]: Setting title to: Document Title!
Mar 28 05:09:42 reMarkable printer.arm[2209]: %PDF-1.5
Mar 28 05:09:42 reMarkable printer.arm[2209]: PDF begin
Mar 28 05:09:42 reMarkable printer.arm[2209]: Saving metadata to /home/root/.local/share/remarkable/xochitl/c94d476e-d51d-4bb3-837b-98cb6948ef21.metadata
Mar 28 05:09:42 reMarkable printer.arm[2209]: Saving content file to /home/root/.local/share/remarkable/xochitl/c94d476e-d51d-4bb3-837b-98cb6948ef21.content
Mar 28 05:09:43 reMarkable printer.arm[2209]: Restarting xochitl
This should have been fixed in https://github.com/Evidlo/remarkable_printer/issues/21
Have you reinstalled the printer config since I made that update?
Have you reinstalled the printer config since I made that update?
Yes, I only have my reMarkable a week :-)
Can you point me at the patch that solved this? Is it this one?
I don't see the string "PJL JOB NAME" anywhere in there. Should it be?
It seems to be a regression from https://github.com/Evidlo/remarkable_printer/pull/26. After replacing pdftopdf
with -
, I find that the @PJL JOB NAME
line is not being sent.
You might try two things:
delete the cupsFilter2
line. This worked on my Linux machine, but in the output I see this:
ESC%-12345X@PJL
@PJL JOB NAME = "NPR _ National Public Radio" DISPLAY = "155 evan NPR _ National Public R"
@PJL SET USERNAME = "evan"
...
% This file was generated by pdftopdf
%%PDFTOPDFNumCopies : 1
%%PDFTOPDFCollate : false
1 0 obj
<< /Pages 3 0 R /Type /Catalog >>
endobj
2 0 obj
...
So it seems like cups will use pdftopdf
even though the cupsFilter
line doesn't explicitly say so. Maybe CUPS is smart enough to automatically use cgpdftopdf
on OSX?
replace -
with cgpdftopdf
for the cupsFilter2
line like you had originally suggested. This change is not portable to Linux as you are probably aware.
If the first doesn't work on OSX but the second does, then we may want to symlink cgpdftopdf
to pdftopdf
in the install script.
Also something I found useful when debugging this ppd stuff was to use netcat to listen on port 9100 and change the printer IP to localhost.
[evan@blackbox ~] nc -l -p 9100 | head -n 20
-12345X@PJL
@PJL JOB NAME = "NPR _ National Public Radio" DISPLAY = "154 evan NPR _ National Public R"
@PJL SET USERNAME = "evan"
@PJL SET RENDERMODE=COLOR
@PJL SET DUPLEX=OFF
@PJL SET PAPER=LETTER
@PJL SET RESOLUTION=600
@PJL SET BORDERLESS=ON
@PJL SET EDGETOEDGE=YES
@PJL SET JOBOFFSET=ON
@PJL SET LOWSUPPLIES=CONTINUE
@PJL SET MANUALDUPLEX=OFF
@PJL SET MANUALFEED=OFF
@PJL SET OVERRIDEA4WITHLETTER=YES
@PJL SET RET=NOTSET
@PJL ENTER LANGUAGE = PDF
%PDF-1.4
%¿÷¢þ
% This file was generated by pdftopdf
%%PDFTOPDFNumCopies : 1
It looks to me like the issue is that cgpdftopdf doesn't pass any PJL commands. That's been pretty consistently true with various things I have tried. Removing cupsFilter2 and directly passing cgpdftopdf doesn't seem to help.
I've been looking at hacking a wrapper script around cgpdftopdf which would add the extra lines PJL lines as an experiment.
38f9d35c0f7b:Downloads gavinmc$ nc -l 127.0.0.1 9100 | head -10
%PDF-1.3
%?????????
4 0 obj
<< /Length 5 0 R /Filter /FlateDecode >>
stream
In case it triggers anything in your head, I've noted this "NO filtering is needed" output from cgpdftopdf when I run it.
DEBUG: Trying /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/Resources/en.lproj/cups_apple.strings
DEBUG: Message catalog filename is "/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/Resources/en.lproj/cups_apple.strings".
DEBUG: cgpdftopdf - NO filtering is needed; passing data through.
This is the help output.
38f9d35c0f7b:~ gavinmc$ /usr/libexec/cups/filter/cgpdftopdf --help
DEBUG: Trying /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/Resources/en.lproj/cups_apple.strings
DEBUG: Message catalog filename is "/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/Resources/en.lproj/cups_apple.strings".
Usage: /usr/libexec/cups/filter/cgpdftopdf job-id user title copies options [file]
This filter manually inserts the PJL line before the PDF content:
/usr/lib/cups/filter/rmfilter
#!/bin/bash
# send job name
echo -n "@PJL JOB NAME = "
echo "\"$3\""
# accept PDF as argument or from stdin
if [ -n "$6" ]
then
cat "$6"
else
cat
fi
There was an issue with the filter above, which I corrected. I created an rmfilter
branch which should install the filter automatically along with a .ppd that is configured to use it. Can you try it out?
This filter manually inserts the PJL line before the PDF content:
Yeah, hand-hacking that in works alright. I think in an ideal world, one would want to still use cgpdftopdf to do other transforms it might need to, something like this:
#!/bin/bash
# send job name
echo -n "@PJL JOB NAME = "
echo "\"$3\""
# accept PDF as argument or from stdin
if [ -n "$6" ]
then
echo $(/usr/libexec/cups/filter/cgpdftopdf "$@")
else
cat | /usr/libexec/cups/filter/cgpdftopdf "$@"
fi
This seems to work fine. I've only tested the second branch which uses the "cat".
xochitl uses pdfium which I think is much more featureful than a typical PDF printer, so I don't think pdftopdf or cgpdftopdf are going to do much here.
Ah, fair enough then, I assumed it would be potentially reading options from position 4 in the CLI (which seems to allow N-UP etc):
Usage: /usr/libexec/cups/filter/cgpdftopdf job-id user title copies options [file]
In the Makefile:
sudo cp rmfilter /usr/lib/cups/filter
I think you need something like this to put the file in /usr/libexec/cups/filter on a Mac:
sudo cp rmfilter $(cups-config --serverbin)/filter
Seems like cups-config
isn't available on Linux. May need to check the distro to set the right install path.
Seems like cups-config isn't available on Linux. May need to check the distro to set the right install path.
That's a pain. Seems it's part of the dev tools on Ubuntu (which nobody will have installed).
ubuntu@ip-172-31-9-203:~$ cups-config
Command 'cups-config' not found, but can be installed with:
sudo apt install libcups2-dev
There's a recipe based on "uname -s" here:
https://stackoverflow.com/questions/3466166/how-to-check-if-running-in-cygwin-mac-or-linux
Is this still happening with the latest release?
I got my first reMarkable recently and started with 2.6.1.71. After hacking around the problem described in #23 which resulted in an empty file), I am still seeing an issue with the printed files always being called "Printed".
Looking at the code here:
https://github.com/Evidlo/remarkable_printer/blob/master/main.go#L130-L152
it looks like the correct filename should be taken from the contents of the jetdirect preamble "@PJL JOB NAME". However,
My working theory is that the PJL statements are not being sent to the print service at all and that this must be some problem with either the PPV (I'm using the one in this package), the CUPS filter (on Mac Catalina 10.15.7) or how I have configured the printer.