GithubHelp home page GithubHelp logo

evidlo / remarkable_printer Goto Github PK

View Code? Open in Web Editor NEW
254.0 13.0 21.0 772 KB

Native printing to reMarkable.

License: GNU General Public License v3.0

Makefile 22.70% Go 69.30% Shell 8.00%
remarkable-tablet

remarkable_printer's Introduction

remarkable_printer

Print natively to your reMarkable wirelessly with no extensions or reMarkable cloud.

Quick Start

Connect the reMarkable via USB and make sure it has internet access.

Connect to the reMarkable with SSH and execute

wget -O - http://raw.githubusercontent.com/Evidlo/remarkable_printer/master/install.sh | sh

Then configure your OS to print to the reMarkable, shown below.

Adding the reMarkable as a printer

Linux/OSX (easy)

make install_config host=10.11.99.1

Linux (manual)

We will add the reMarkable as an Appsocket/JetDirect printer and use the PDF printer driver.

$ sudo system-config-printer
# Add > Network Printer > AppSocket/HP JetDirect
# Enter the address/hostname of the device (10.11.99.1 for USB connected device)
# Forward > Generic > Forward > PDF > Forward
# Set the printer name and save

You may need to install system-config-printer first.

OSX (manual)

See Add a network printer by its IP address. Use 10.11.99.1 for the address and HP Jetdirect for the protocol.

Windows (manual)

See here

Caveats

No authentication, so keep WiFi off while not in use.

How it works

Virtually all network printers accept raw Postscript/PDF data on TCP port 9100 via the Appsocket/HP Jetdirect protocol. Sometimes this data is preceded by a few plaintext lines telling the printer information such as the print job name and print settings.

This setup simply listens on TCP 9100 and upon data sent waits for a PDF header, then begins saving data to a pdf file (while also creating the accompanying .metadata file) and then exits again, waiting for the next connection on the port to repeat the procedure. The output filename is extracted from the print job name line, if it exists.

Testing on host

$ make printer.x86
$ ./printer.x86 -h
Usage of ./printer.x86:
  -debug
        enable debug output
  -host string
        override bind address (default "0.0.0.0")
  -port string
        override bind port (default "9100")
  -restart
        restart xochitl after saving PDF
  -test
        use /tmp as output dir

Debugging

On the reMarkable (via SSH)

journalctl --unit printer -f

Then try to print a document.

remarkable_printer's People

Contributors

beardhatcode avatar cherti avatar evidlo avatar gavinmcc avatar gnomiro avatar gozala avatar kesmit13 avatar sergiusens avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

remarkable_printer's Issues

does not work with starters (remux, oxide, draft)

It seems that the printer restarts xochitl by utilising the systemd service.
stdout, err := exec.Command("systemctl", "restart", "xochitl").CombinedOutput()

Most (all?) starters disable the start of xochitl as a system service and start it by themselves.
The printer should find a way to identify whether to restart xochitl via systemd service or signalling remux, oxide and Co to restart xochitl.

Undeclared dependencies?

make install
env GOOS=linux GOARCH=arm GOARM=5 go build -o printer.arm
main.go:15:2: cannot find package "github.com/google/uuid" in any of:
	/usr/lib/go/src/github.com/google/uuid (from $GOROOT)
	/home/user/workspaces/go/src/github.com/google/uuid (from $GOPATH)
make: *** [Makefile:5: printer.arm] Error 1

Printer works best for me with custom paper size on windows

Maybe this could be an addition to docs:
I use remarkable_printer on win10 with a custom paper-size of 15,70cm x 20,96cm (the default papersize for pdf-exports from rM2). With that format I have a good readable text size and do not have to adjust the pdf view in rM2, because toolbar fits perfect in the default left margin.

Therefore I had to:

  1. define a custom paper size "reMarkable" in print server-settings
  2. Enable custom paper sizes for the PrintToPdf-based reMarkable-Printer (a guide for that can be found in https://franklinheath.co.uk/2015/08/29/custom-page-sizes-for-microsoft-print-to-pdf/)

Now I can just select this format as a print layout e.g. in Outlook, OneNote or Browser and i have a very good readable print in my reMarkable.

On OSX - how to change PS to PDF ?

Following the instruction:

Screenshot 2022-05-18 at 11 43 49

one ends up with a Generic printer that sends PDF and as a result; an error

  May 18 09:39:34 reMarkable printer.arm[2470]: Couldn't find PDF start

on the side of the Remarkable. How does one force on OSX the sending of a pure PDF ?

Automatic installation not working after release 9

install.sh tries to download /releases/latest/download/release.zip, but release 9 does not contain a release.zip.
So installation is currently only possible by either building it, or manually downloading the older release.

Feature: Rename sent document to website title

My workflow is as follows:

I see an interesting article, send it to the remarkable with this tool.
It has the name of 'Printed' and I rename it to something else.

Is there anyway to change the name of the sent PDF to for example the website title? Is it even possible to send information via the printer?

[Feature Request] Split pages in two

I have fairly low vision and often find reading one printed page on the remarkable is quite difficult. As such, I cut each page in half before sending it to the remarkable. I would also like to be able to do this using your printer script.

It seems to me that there are two possible ways to do this:

  1. Somehow add in the .pdd file a new page size that is half the current 'remarkable' size, and let the remarkable scale the page up on its own.

  2. Create a new printer device that:

    1. Prints to a pdf.
    2. Cuts the page in half
    3. Sends this new pdf to be printed by your existing printer.

Option #1 seems better (and easier) to me, but I don't really know enough about CUPS (or whatever the printing subsystem for linux is) to do it myself (at least not yet).

Printed File Has No Data

I had this installed and working great. Updated to rM sw 3.0 which updated the IP address. I deleted the original install and reinstalled the native printer hack, chose existing driver, and then went back to chnage driver to MS Print to PDF. Now I am getting only one page no matter how many pages (tried in Excel and Word) and with no data - blank one page. Checked the MS Print to PDF printer and it printed a test page with printer data.

Appreciate thoughts on how to fix this.

pdftopdf (in PPV) is not available on OS X catalina

Following #6 I used the PPV and lpadmin to set up on a mac, but I got an error in the CUPS interface that pdftopdf is not present.

38f9d35c0f7b: gavinmc$ ls /usr/libexec/cups/filter/
cgbannertopdf   cgpdftopdf      cgpdftoraster   commandtops     pstoappleps     pstopdffilter   rastertoepson   rastertolabel   rastertotiff    
cgimagetopdf    cgpdftops       cgtexttopdf     gziptoany       pstocupsraster  pstops          rastertohp      rastertopwg     rastertourf 

This patch seemed to solve this for me, ensuring that raw PDF is sent to the reMarkable jetdirect socket:

38f9d35c0f7b:remarkable_printer gavinmc$ git diff
diff --git a/remarkable.ppd b/remarkable.ppd
index 9fcf20d..9c0791a 100644
--- a/remarkable.ppd
+++ b/remarkable.ppd
@@ -40,7 +40,7 @@
 *JCLToPDFInterpreter: "@PJL ENTER LANGUAGE = PDF<0A>"
 *JCLEnd:              "<1B>%-12345X@PJL EOJ <0A><1B>%-12345X"
 *cupsFilter: "application/vnd.cups-pdf 0 -"
-*cupsFilter2: "application/pdf application/vnd.cups-pdf 0 pdftopdf"
+*cupsFilter2: "application/pdf application/vnd.cups-pdf 0 cgpdftopdf"
 
 *OpenGroup: General/General
 *JCLOpenUI *PageSize/Page Size: PickOne

Failing to install on macOS

when I used make install_config host=10.11.99.1, it showed make: *** No rule to make target install_config'. Stop.`
But when I tried to install manually, I failed to print. Nothing appears on my remarkable and the debug shows

`Jun 11 10:38:30 reMarkable systemd[1]: printer.service: Main process exited, code=exited, status=1/FAILURE
Jun 11 10:38:30 reMarkable systemd[1]: printer.service: Failed with result 'exit-code'.
Jun 11 10:38:30 reMarkable systemd[1]: printer.service: Scheduled restart job, restart counter is at 1.
Jun 11 10:38:30 reMarkable systemd[1]: Stopped Native printing to reMarkable.
Jun 11 10:38:30 reMarkable systemd[1]: Started Native printing to reMarkable.
Jun 11 10:38:30 reMarkable printer.arm[420]: Debugging enabled
Jun 11 10:38:30 reMarkable printer.arm[420]: Listening on 0.0.0.0:9100
printer.service
sudo lpadmin -p reMarkable -E -o printer-error-policy=abort-job -v socket://10.11.99.1:9100 -P remarkable.ppd

`

I read some of issues posted on Issues section and tried to solve it on my own but I couldn't understand what they were talking about due to lack of professional knowledge......

Can't send PDF's with PDF version 1.4 to remarkable

Browser: Chromium
OS: Linux

Printing with Chromium https://github.com/Evidlo/remarkable_printer gives an error.

Steps to reproduce

  1. Print to reMarkable in Chromium (Print to PDF and use pdfinfo to verify that your browser creates PDF with PDF version 1.4)
reMarkable: ~/ ./printer.arm -host 0.0.0.0 -port 9100 -debug -restart  
Saving PDF to /home/root/.local/share/remarkable/xochitl/10376b64-c106-43d2-a1af-3cbfbc702c94.pdf
[%PDF-1.4
]
[PDF begin]
[Invalid PDF]

Workaround

  1. Save to PDF in Chromium
  2. Convert PDF to PDF version 1.6 $ gs -q -sDEVICE=pdfwrite -dCompatibilityLevel=1.6 -o Evidlo_remarkable_printer_\ Native\ printing\ to\ reMarkable_V1.6.pdf Evidlo_remarkable_printer_\ Native\ printing\ to\ reMarkable_.pdf
  3. Send with lp
reMarkable: ~/ ./printer.arm -host 0.0.0.0 -port 9100 -debug -restart                                                                                                               
Listening on 0.0.0.0:9100
Saving PDF to /home/root/.local/share/remarkable/xochitl/ae491792-439c-466d-8d4b-34eb3c15ee9e.pdf
[%PDF-1.6
]
[PDF begin]
Saving metadata to /home/root/.local/share/remarkable/xochitl/ae491792-439c-466d-8d4b-34eb3c15ee9e.metadata```

No such file or directory

Sorry if the title's misleading. Last a few lines didn't seem to go well. Any advice to spare?

Darwin:remarkable_printer-master me$ make install
env GOOS=linux GOARCH=arm GOARM=5 go build -o printer.arm
ssh-add
Enter passphrase for /Users/me/.ssh/id_rsa: 
Identity added: /Users/me/.ssh/id_rsa ([email protected])
ssh [email protected] systemctl stop printer
scp printer.arm [email protected]:
printer.arm                                             100% 3238KB   6.4MB/s   00:00    
scp printer.service [email protected]:/etc/systemd/system
printer.service                                         100%  154    79.5KB/s   00:00    
ssh [email protected] <<- ENDSSH
Pseudo-terminal will not be allocated because stdin is not a terminal.
systemctl daemon-reload
make: systemctl: No such file or directory
make: *** [install] Error 1

Allow different service name for restart

Hi,

First, thank you for this project, It's very helpful!
I'd like to request one small feature: It would be nice to make the name of the restarted service configurable in order for this to work with different launchers. I am using the remux launcher, and therefore I have to restart the service remux instead of xochitl.

Best Regards
Dorian

Restart xochitl using remux and oxide API instead of restarting everything.

if *restart {
services := []string{"xochitl", "remux", "tarnish", "draft"}
for _, service := range services {
_, exitcode := exec.Command("systemctl", "is-active", service).CombinedOutput()
if exitcode == nil {
debug("Restarting " + service)
stdout, err := exec.Command("systemctl", "restart", service).CombinedOutput()
if err != nil {
fmt.Println(service + " restart failed with message:", string(stdout))
}
}
}
}

Instead of restarting all of the currently running applications, even if xochitl isn't running, this code should be a little smarter and instead use the remux or oxide APIs to restart the xochitl application if it's running.

Remux launch API: https://github.com/rmkit-dev/rmkit/tree/master/src/remux#launch-api-020
Example:

if killall -q -0 xochitl; then
  killall -SIGCONT xochitl
  killall xochitl
  i=0
  while killall -q -0 xochitl; do
    sleep 1;
    i=$((i+1))
    if [[ "$i" -gt 5 ]]; then
      killall -9 xochitl
    fi
  done
fi
echo 'launch xochitl' > /run/remux.api

Oxide Apps API: https://oxide.eeems.codes/documentation/api/02_apps.html
Oxide CLI tool for interacting with the API: https://oxide.eeems.codes/documentation/01_usage.html#examples-of-usage
Example:

app=$(rot apps get runningApplications | jq -r '.xochitl' | sed 's|/codes/eeems/oxide1/||')
if [[ "${app}" != "null" ]]; then
  rot -o Application:$app apps call stop
  rot -o Application:$app apps call launch
fi

Adding the reMarkable as a printer for windows

I added my reMarkable as printer in win10.
I followed your instructions to install and start the printer service on the reMarkable using a VM with ubuntu.

To add the printer in windows, I followed this instructions:

  1. Select “Start” and type “printers” in the search box.
  2. Choose “Printers & scanners“.
  3. Select "Add a printer or a scanner"
  4. Wait few seconds and click on "The printer I that I want isn’t listed" option
  5. Select “Add a printer using a TCP/IP address or hostname” , then select “Next“.
  6. Select “TCP/IP Device” in the “Device type” list.
  7. Enter the IP address of the printer (10.11.99.1). Select “Next“.
  8. Wait few seconds to allow windows to find your printer
  9. Select "Hewlett Packard Jet Direct"
  10. Select "Microsoft" and the "Microsoft Print to PDF"
  11. Rename the printer, "reMarkable" for example

Works fine

Print to pdf driver removed from recent version of Windows 10

I found a weird problem and even weirder workaround for printing from Windows 10.

In the newest version of Windows 10 the "Microsoft Print to PDF" driver seem to have been removed from the drivers list (but it's still in the system somewhere) as long as you have the default Print to PDF printer that comes with Windows 10. You can enable it from "Turn Windows Features on or off"

So to add the printer to Windows 10 I had to add two steps to the old procedure:

Select “Start” and type “printers” in the search box.
Choose “Printers & scanners“.
Select "Add a printer or a scanner"
Wait few seconds and click on "The printer I that I want isn’t listed" option
Select “Add a printer using a TCP/IP address or hostname” , then select “Next“.
Select “TCP/IP Device” in the “Device type” list.
Enter the IP address of the printer (10.11.99.1 for USB connection or IP of you wifi connection). Select “Next“.
Wait few seconds to allow windows to find your printer
Select "Hewlett Packard Jet Direct"
Select "Microsoft" and the "Microsoft Print to PDF"
**If the "Microsoft Print to PDF" driver is not on the list, choose any other driver (doesn't matter which one).
Rename the printer, "reMarkable" for example
**If you chose another driver above, go to the Printers & Scanners/Manage/Printer Properties/Advanced
In the Driver: drop down menu choose "Microsoft Print of PDF" which is now visible, click OK

need to reboot remarkable to see printed.

I have version 2.7.0.51 with ddvk hacks and with toltec installed koreader and remux
When printing to the remarkable the file doesn't show up in the list. When I restart the device the file printed appears.

Filename is always "Printed" on reMarkable

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,

  1. I do see the "PDF begin" (indicating we are in debug mode)
  2. I never see the debug line "Setting title to:" which suggests we never set the title
  3. I never see any @pjl debug lines suggesting there are none (in debug mode, they would all be logged).
Mar 27 07:14:58 reMarkable printer.arm[2209]: Saving PDF to: /home/root/.local/share/remarkable/xochitl/f1a24f5d-8b0a-4fc6-abd6-8f5ab05fc691.pdf
Mar 27 07:14:58 reMarkable printer.arm[2209]: %PDF-1.3
Mar 27 07:14:58 reMarkable printer.arm[2209]: PDF begin
Mar 27 07:14:58 reMarkable printer.arm[2209]: Saving metadata to /home/root/.local/share/remarkable/xochitl/f1a24f5d-8b0a-4fc6-abd6-8f5ab05fc691.metadata
Mar 27 07:14:58 reMarkable printer.arm[2209]: Saving content file to /home/root/.local/share/remarkable/xochitl/f1a24f5d-8b0a-4fc6-abd6-8f5ab05fc691.content
Mar 27 07:14:58 reMarkable printer.arm[2209]: Restarting xochitl

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.

Failing to print from MacOS

Here's output of journalctl -f --unit printer which suggest something is wrong with pdf although I'm not sure why

Jul 10 07:21:26 reMarkable printer.arm[770]: Listening on 0.0.0.0:9100
Jul 10 07:21:46 reMarkable printer.arm[770]: Saving PDF to /home/root/.local/share/remarkable/xochitl/e0d00f7b-0bca-4f65-87d2-5f0189269b3e.pdf
Jul 10 07:21:46 reMarkable printer.arm[770]: Invalid PDF
Jul 10 07:21:46 reMarkable systemd[1]: printer.service: Main process exited, code=exited, status=1/FAILURE
Jul 10 07:21:46 reMarkable systemd[1]: printer.service: Failed with result 'exit-code'.
Jul 10 07:21:47 reMarkable systemd[1]: printer.service: Service hold-off time over, scheduling restart.
Jul 10 07:21:47 reMarkable systemd[1]: printer.service: Scheduled restart job, restart counter is at 3.
Jul 10 07:21:47 reMarkable systemd[1]: Stopped Native printing to reMarkable.
Jul 10 07:21:47 reMarkable systemd[1]: Started Native printing to reMarkable.
Jul 10 07:21:47 reMarkable printer.arm[775]: Listening on 0.0.0.0:9100

New release with updated ExecStart path

Currently if you follow the instructions in the README you will end up with a non-working printer service since install.sh is from master but the downloaded release.zip has the version of printer.service from before this commit: df87000

Publishing a new release (and updated release.zip) will fix this issue.

BTW, thanks for creating this, it's very handy!

Add License

There doesn't seem to be a license included with this. So it's not clear what users can and cannot do with the code.

Printed File Location

Thanks for this great tool. Is their somewhere in the code where I can edit where the file goes when printed? I want it to go into folder I have on my rM called "Print"

Feature: Little GUI to select save location and name and xochitl restart

Hi,
would you be interested in a little GUI which pops up instead of saving the PDF directly and restart xochitl?
This GUI could ask for the location where to save, the file name, potentially for a few other details and finally give the user the choice to restart xochitl.
One key-feature could be to make choices and select them as "Set as standard for this session". Which, as long as the GUI is active, those settings would be applied for all incoming jobs till the user closes the GUI. That would allow people to go for a designated folder, a naming scheme, some other settings as standard, no restart of xochitl in between and send one file after another... as soon as it is done, they select close and restart xochitl call it done.

What driver do you use on a Mac?

I'm trying to follow the installation instructions and it sounds like you need a PDF driver in order to use this on a Mac, but I'm not sure how to get one. When adding a printer, the only options I get are Generic PostScript Printer, Generic PCL Printer, and AutoSelect. I tried the PostScript printer, but I get errors on the reMarkable. Do you have more detailed instructions for this setting on the Mac?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.