mb1986 / rm-hacks

Small improvements and tweaks for rM devices, covering both rM1 and rM2.
Other
507 stars 11 forks source link

Crop from PDF using Draw2jd #136

Closed pragmatically-dev closed 8 months ago

pragmatically-dev commented 8 months ago

Maybe it could be possible by integrating

https://drawj2d.sourceforge.io/

jar bin into the remarkable and use it by taking advantage of the select and convert.

My current workflow to achieve this is the following:

1) I created a Google account to receive the page from the remarkable

2) coded an Appscripts project to watch the inbox and If there's a file, it upload it to a Gdrive folder

3) I use Drive sync to fetch the files in my Window PC

4) A rust program is in charge of Look at the folder every 1 min; if there's a file it save to a json as db (to prevent duplicates) and use Draw2jd to convert the file to the remarkable file ( it Generates a .zip file) to later on upload it via Rmapi

The result is that you get a note with all its content converted into rmlines, that you can crop, copy, move etc.

The main problem of this workflow: It is slow, the whole process takes 2 to 4 minutes due to the limitations of Appscripts time triggers.

It would be amazing to integrate Draw2jd directly into the rm2 and use it offline

I know that this is something that the remarkable team should handle, but they didn't :(

Thank you again for you work!

pragmatically-dev commented 8 months ago

https://github.com/mb1986/rm-hacks/assets/59318726/b28f6f05-23c7-4994-a992-d79ceb731205

PepikVaio commented 8 months ago

Great, I can also do this but only on PC (prepare document and upload to reMarkable using RCU).

You can do it directly in reMarkable????

pragmatically-dev commented 8 months ago

Yeah, when everything is set up, I only send the page via email and I wait till the process complete, the downfall is the slowness of the process, 3 min to each page that you want to convert is not that productive

pragmatically-dev commented 8 months ago

Would be amazing to have it inside the rm2, idk if it is possible

PepikVaio commented 8 months ago

Yeah, when everything is set up, I only send the page via email and I wait till the process complete, the downfall is the slowness of the process, 3 min to each page that you want to convert is not that productive

Can you give me directions? Step by step? The instructions in the first post are insufficient for me.

Thank you very much

pragmatically-dev commented 8 months ago

The workflow is something like this

Quick sheets.pdf

basically the only job of the application made in rust is to check if there is a new file in the folder synced with Google drive. If there is a new file and that file is not found in the Json file, the app saves its name in a json file, then creates a file with the ".hcl" extension, there it places the detected image or PDF (https:/ /sourceforge.net/p/drawj2d/wiki/reMarkable/) to later run the application: drawj2d -Trmapi page.hcl, once that process finishes the app in rust, run the Rmapi application and upload the created output.zip file. As you can see, the app made in Rust serves as a bridge between Drawj2d and Rmapi, while the project made in appscript is responsible for being a bridge between the tablet and Google Drive. The critical piece is the synchronization between the cloud folder and the folder on the local machine.

pragmatically-dev commented 8 months ago

I'll try to create a step by step guide when I return home, but here you have some resources:

https://developers.google.com/apps-script/reference/gmail/gmail-app

https://developers.google.com/apps-script/reference/drive

https://developers.google.com/apps-script/guides/triggers/installable

https://github.com/juruen/rmapi

https://sourceforge.net/p/drawj2d/wiki/reMarkable/

And the bridge between drawj2d and Rmapi can be coded in the programming language of your preference

Those libs are interesting:

https://github.com/facebook/watchman

https://marketsplash.com/tutorials/node-js/node-js-execute-command-line/

dstango commented 8 months ago

@pragmatically-dev that's a cool tool! :-)

I checked a little and found this: https://www.reddit.com/r/RemarkableTablet/comments/nawmzm/comment/gydvglx/

Someone tried to run exactly drawj2d directly on the remarkable, and file conversion seems to work. So in principle this could be possible.

The hacks would need to provide some extension point to e.g. call some batch script on the rm with the file (or better source/destination file names) as a parameters. You could plug in your drawj2d-script (other people might have other ideas, what they would like to do), and the hacks could then take the output file and create a new entry in the rm directory for it with proper metadata.

Questions to consider beforehand might be how this is behaving performance-wise and how much RAM/disk it requires. But you should be able to try out a conversion directly on the remarkable when following the link above, and get an idea if the performance seems to be practical.

pragmatically-dev commented 8 months ago

Maybe is possible to use the send by email interface and for now just convert the whole page and put the drawj2d raw output into the clipboard by taking advantage of the "select and convert" interface or just create a new page with the rmlines content