reHackable / maxio

Companion daemon for the reMarkable™ paper tablet
GNU Lesser General Public License v3.0
156 stars 53 forks source link

Feature: Combine converted SVG with original PDF documents for better PDF export #3

Closed justfortherec closed 6 years ago

justfortherec commented 7 years ago

This is probably a feature for the far future. I would still like to document it.

PDF documents imported to the remarkable desktop app are stored (cached?) in $HOME\AppData\Roaming\remarkable\desktop\ (that is on Windows; I assume this is at similar locations on other platforms).

The app seems to generate a UUID at import time. The following files are stored for each imported file:

As you might already have noticed, remarkables export functionality is lacking (and buggy). rM2svg could be used to create a better export experience by overlaying the original document with the converted *.lines.

I understand that this might currently be out of scope for this project. So please consider this as inspiration and shared knowledge base instead of a demand.

edupont commented 7 years ago

Can you please check if this can be done by Imagemagick composite command?

The format of PDF files is far from trivial. I wanted to add a text search functionality in the reMarkable, still experimenting on that.

The PDF format has the concept of "Annotations", that we could use for that. That will require more experiments or PDF experts to get right.

The plus side of having it running outside of the tablet is that it allows to bind to PDF editing libraries, which was not possible from within the reMarkable (libpdfium is in there, maybe that one would work).

Keep ideas and patches coming. Émeric

On 2017-11-27 22:14, Franz Geiger wrote:

This is probably a feature for the far future. I would still like to document it.

PDF documents imported to the remarkable desktop app are stored (cached?) in $HOME\AppData\Roaming\remarkable\desktop\ (that is on Windows; I assume this is at similar locations on other platforms).

The app seems to generate a UUID at import time. The following files are stored for each imported file:

  • .pdf (the original document without annotations)
  • .pagedata (here it only says Blank, no clue what it means)
  • .content (JSON formated meta data)
  • .metadata (some more JSON formated meta data)
  • .lines (annotations overlay for the document as drawn on the device).

As you might already have noticed, remarkables export functionality is lacking (and buggy). rM2svg could be used to create a better export experience by overlay the original document with the converted *.lines.

I understand that this might currently be out of scope for this project. So please consider this as inspiration and shared knowledge base instead of a demand.

-- You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub [1], or mute the thread [2].

*

Links:

[1] https://github.com/edupont/maxio/issues/3 [2] https://github.com/notifications/unsubscribe-auth/AFb7M4TxJwHC9AnjjbbliXeE3B9AZUGAks5s6yYZgaJpZM4QsTZj

justfortherec commented 7 years ago

Can you please check if this can be done by Imagemagick composite command?

Haven't tried ImageMagick yet. I have experimented with GhostView, pdftk and cpdf with some success. Remaining issue is mostly properly scaling and aligning rendered annotations.

The format of PDF files is far from trivial. I wanted to add a text search functionality in the reMarkable, still experimenting on that.

How do you get access to the remarkable? Is there any dev documentation?

The PDF format has the concept of "Annotations", that we could use for that. That will require more experiments or PDF experts to get right.

I agree, this would be the right way to do it.

The plus side of having it running outside of the tablet is that it allows to bind to PDF editing libraries, which was not possible from within the reMarkable (libpdfium is in there, maybe that one would work).

It seems as if the official desktop client for remarkable also does that on the host (i.e. in the desktop client and not on the tablet).

edupont commented 7 years ago

On 2017-11-28 13:14, Franz Geiger wrote:

The format of PDF files is far from trivial. I wanted to add a text search functionality in the reMarkable, still experimenting on that.

How do you get access to the remarkable? Is there any dev documentation?

The About page shows the necessary settings for an SSH connection as root to the reMarkable. https://remarkable.engineering/ contains further resources and a toolchain to compile your own applications.

trou commented 6 years ago

Haven't tried ImageMagick yet. I have experimented with GhostView, pdftk and cpdf with some success. Remaining issue is mostly properly scaling and aligning rendered annotations.

Have you made any progress ? I just tried a quick workflow:

the result looks good except that the annotations are not aligned :(

edupont commented 6 years ago

Thanks for the experiments.

the result looks good except that the annotations are not aligned

This matches the report from @justfortherec :

Remaining issue is mostly properly scaling and aligning rendered annotations.

Do you have more details about the misalignment? What transformations are required, is it always the same transformations, or does it depend on the PDF file? Is there a density-dependent scaling to apply?

justfortherec commented 6 years ago

The misalignment is also an issue that reMarkable's official export has.

I have an initial proof of concept which uses poppler to add annotations to a PDF. We could try adding the lines from a reMarkable as annotations based on the parser you wrote (instead of SVG output).

However, I don't have much time for experiments at the moment and this will be a slow process if I do it.

edupont commented 6 years ago

I only noted the misalignment when annotating PDF documents after having used the crop tool. Are they also misaligned if you never crop?

Did you publish the proof of concept somewhere? I could help on extracting the data from the .lines files. Are you using the LineAnnotation from Poppler?

trou commented 6 years ago

I only noted the misalignment when annotating PDF documents after having used the crop tool. Are they also misaligned if you never crop?

I did not crop. However, I've tried with a PDF of aspect ratio 0.75, it works perfectly. So the problem is to understand how to scale the input PDF to the right ratio.

trou commented 6 years ago

A colleague did some work on a fork: https://github.com/phil777/maxio/blob/master/tools/rM2svg which uses the original PDF to scale the annotation PDF, it works ! steps:

./rM2svg -i input.lines -p input.pdf -o annot.pdf
pdftk input.pdf multistamp annot.pdf output final.pdf

The only problem is that the stroke calculation he did reimplement are not as good.

justfortherec commented 6 years ago

Is this closed by #7?

edupont commented 6 years ago

Yes, thanks for pointing that out.