ricklupton / rmc

Convert to/from v6 .rm files from the reMarkable tablet
MIT License
57 stars 14 forks source link

lost positions by converting to PDF #4

Closed Utopiah closed 1 year ago

Utopiah commented 1 year ago

here is the source https://old.reddit.com/r/RemarkableTablet/comments/11mxyq4/usb_keyboards_work_now/jbowond/ and here is the log

fabien@fabien-CORSAIR-ONE-i160:~/Downloads$ rmc 059452a0-a547-47f3-bb13-bae9407137e8.rm -o file.pdf 
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.MainBlockInfo'> starting at 108, length 7, only read 5
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.MainBlockInfo'> starting at 123, length 25, only read 20
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 3077, length 275, only read 272
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 3385, length 247, only read 244
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 3665, length 135, only read 132
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 3833, length 513, only read 510
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 4379, length 219, only read 216
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 4631, length 374, only read 370
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 5038, length 94, only read 90
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 5165, length 192, only read 188
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 5390, length 486, only read 482
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 5909, length 108, only read 104
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 6050, length 570, only read 566
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 6653, length 500, only read 496
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 7186, length 346, only read 342
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 7565, length 332, only read 328
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 7930, length 290, only read 286
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 8253, length 374, only read 370
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 8660, length 402, only read 398
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 9095, length 192, only read 188
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 9320, length 514, only read 510
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 9867, length 472, only read 468
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 10372, length 220, only read 216
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 10625, length 360, only read 356
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 11018, length 178, only read 174
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 11229, length 360, only read 356
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 11622, length 220, only read 216
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 11875, length 177, only read 173
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 12085, length 597, only read 593
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 12715, length 275, only read 271
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 13023, length 205, only read 201
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 13261, length 443, only read 439
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 13737, length 163, only read 159
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 13933, length 457, only read 453
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 14423, length 471, only read 467
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 14927, length 331, only read 327
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 15291, length 541, only read 537
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 15865, length 177, only read 173
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 16075, length 149, only read 145
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 16257, length 541, only read 537
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 16831, length 541, only read 537
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 17405, length 345, only read 341
WARNING:rmscene.tagged_block_reader:<class 'rmscene.tagged_block_reader.SubBlockInfo'> starting at 17783, length 541, only read 537

so most of the content seems to be there but incorrectly positioned. Note that it comes from a reMarkable 1 running 3.2 and files are not mine but thought it could be interesting to verify before the official keyboards ship.

ricklupton commented 1 year ago

Yes, getting the positioning right needs proper parsing of the anchoring positions relative to the text. I’ve got a version nearly working that does this, hope can release it soon.

Utopiah commented 1 year ago

Super, happy to test it when it's out.

Luckily for me (sigh) the official keyboard for the reMarkable 2 seems to be quite delayed (some people receiving next week but otherwise website saying 30+ days) so I'm not in such a rush anymore.

Azeirah commented 1 year ago

Yes, getting the positioning right needs proper parsing of the anchoring positions relative to the text. I’ve got a version nearly working that does this, hope can release it soon.

Do you mean that the data in the anchoring blocks has been incorrect so far? No wonder nobody could make sense of how to use the data to draw when text was present

ricklupton commented 1 year ago

No, “parsing” was the wrong word, as far as I know the data is parsed correctly — it’s just that the coordinates of the pen strokes can be given relative to specific text characters, so to draw it properly you need to figure out where the text goes first. I’ve got a version that seems to work ok for doing this, just need to tidy up and get the page margins in the right place.

ricklupton commented 1 year ago

@Utopiah can you try the new version 0.2.0a0 of rmc? (e.g. using pipx install rmc or pipx upgrade rmc if you already have it, and check the version with rmc --version).

Still some known issues such as

But the overall positioning should be about right now.

Utopiah commented 1 year ago

Unfortunately


(deck@steamdeck ~)$ pipx upgrade rmc
rmc is already at latest version 0.1.1 (location: /home/deck/.local/pipx/venvs/rmc)

but feel free to try directly from the test file if you want.

ricklupton commented 1 year ago

You may need to use pipx upgrade --pip-args '--pre' <pkg> to allow prereleases, and/or specify the package version directly, or run directly from git.

I tried your test file thanks, just in case you want to see how it’s doing now.

Utopiah commented 1 year ago

Thanks, gave it a go via pipx upgrade --pip-args='--pre' rmc thus version 0.2.0a0 but getting on rM2 3.2.3.1595 with Type Folio :

fabien@fabien-CORSAIR-ONE-i160:~/Prototypes/rmc-test$ scp -r remarkable2:/home/root/.local/share/remarkable/xochitl/b6a18af6-2f88-4e5e-8758-39bfb49d44eb .
befa5448-bb6d-4fa4-8b7f-b69b02998562-metadata.json                                                                                                                                                                                                               100%   76     8.9KB/s   00:00    
bcef4e58-8497-4ff4-b676-67f1bda581a9.rm                                                                                                                                                                                                                          100% 1324   147.4KB/s   00:00    
befa5448-bb6d-4fa4-8b7f-b69b02998562.rm                                                                                                                                                                                                                          100% 8814     1.0MB/s   00:00    
35c53c13-3984-4663-be42-229b5b835dbf.rm                                                                                                                                                                                                                          100%   19KB   1.3MB/s   00:00    
fabien@fabien-CORSAIR-ONE-i160:~/Prototypes/rmc-test$ rmc b6a18af6-2f88-4e5e-8758-39bfb49d44eb/bcef4e58-8497-4ff4-b676-67f1bda581a9.rm -o test.pdf
WARNING:rmscene.tagged_block_reader:Some data has not been read. The data may have been written using a newer format than this reader supports.
Traceback (most recent call last):
  File "/home/fabien/.local/bin/rmc", line 8, in <module>
    sys.exit(cli())
  File "/home/fabien/.local/pipx/venvs/rmc/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/fabien/.local/pipx/venvs/rmc/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/fabien/.local/pipx/venvs/rmc/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/fabien/.local/pipx/venvs/rmc/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/fabien/.local/pipx/venvs/rmc/lib/python3.10/site-packages/rmc/cli.py", line 58, in cli
    convert_rm(Path(fn), to, fout)
  File "/home/fabien/.local/pipx/venvs/rmc/lib/python3.10/site-packages/rmc/cli.py", line 138, in convert_rm
    tree = read_tree(f)
  File "/home/fabien/.local/pipx/venvs/rmc/lib/python3.10/site-packages/rmscene/scene_stream.py", line 761, in read_tree
    build_tree(tree, read_blocks(data))
  File "/home/fabien/.local/pipx/venvs/rmc/lib/python3.10/site-packages/rmscene/scene_stream.py", line 736, in build_tree
    raise ValueError(
ValueError: Node does not exist for SceneGroupItemBlock: None
fabien@fabien-CORSAIR-ONE-i160:~/Prototypes/rmc-test$ rmc --version
rmc, version 0.2.0a0
Utopiah commented 1 year ago

Ah... maybe it was an empty page? I tried on the other 2 .rm files and seemed to work well, including typed text!

Utopiah commented 1 year ago

Works well :)