ricklupton / rmc

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

Error when trying to convert .rm file to .pdf or .svg #3

Closed Joogle closed 1 year ago

Joogle commented 1 year ago

Hi, thanks for your work on this! When I try to run either: poetry run rmc -t svg -o file.svg /path/to/file.rm or poetry run rmc /path/to/file.rm -o file.pdf (I installed rmc via poetry) I receive the following error:

Sub-block starting at 8375, length 121, only read 1
Block starting at 8353, length 143, only read 23
Traceback (most recent call last):
  File "/path/to/folder/remarks/.venv/lib/python3.10/site-packages/rmscene/tagged_block_common.py", line 124, in _read_tag_values
    tag_type = TagType(tag_type)
  File "/usr/lib/python3.10/enum.py", line 385, in __call__
    return cls.__new__(cls, value)
  File "/usr/lib/python3.10/enum.py", line 710, in __new__
    raise ve_exc
ValueError: 0 is not a valid TagType

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/path/to/folder/remarks/.venv/bin/rmc", line 8, in <module>
    sys.exit(cli())
  File "/path/to/folder/remarks/.venv/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/path/to/folder/remarks/.venv/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/path/to/folder/remarks/.venv/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/path/to/folder/remarks/.venv/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/path/to/folder/remarks/.venv/lib/python3.10/site-packages/rmc/cli.py", line 37, in cli
    convert_rm(Path(fn), to, fout)
  File "/path/to/folder/remarks/.venv/lib/python3.10/site-packages/rmc/cli.py", line 89, in convert_rm
    blocks_to_svg(blocks, buf)
  File "/path/to/folder/remarks/.venv/lib/python3.10/site-packages/rmc/exporters/svg.py", line 75, in blocks_to_svg
    blocks = list(blocks)
  File "/home/path/to/folder/remarks/.venv/lib/python3.10/site-packages/rmscene/scene_stream.py", line 738, in read_blocks
    yield from _read_blocks(stream)
  File "/path/to/folder/remarks/.venv/lib/python3.10/site-packages/rmscene/scene_stream.py", line 723, in _read_blocks
    yield block_type.from_stream(stream)
  File "/path/to/folder/remarks/.venv/lib/python3.10/site-packages/rmscene/scene_stream.py", line 99, in from_stream
    migration_id = stream.read_id(1)
  File "/path/to/folder/remarks/.venv/lib/python3.10/site-packages/rmscene/tagged_block_reader.py", line 56, in read_id
    self.data.read_tag(index, TagType.ID)
  File "/path/to/folder/remarks/.venv/lib/python3.10/site-packages/rmscene/tagged_block_common.py", line 89, in read_tag
    index, tag_type = self._read_tag_values()
  File "/path/to/folder/remarks/.venv/lib/python3.10/site-packages/rmscene/tagged_block_common.py", line 126, in _read_tag_values
    raise ValueError(
ValueError: Bad tag type 0x0 at position 8385
Azeirah commented 1 year ago

Does exporting to PDF using official ReMarkable software work? IE when you send the relevant notebook as an e-mail attachment to yourself?

ricklupton commented 1 year ago

@Joogle can you share the file that causes the error, or ideally a minimal small example that also causes the problem, if it is not private?

Joogle commented 1 year ago

@Azeirah, @ricklupton I'll try to test the official software and share the file later, when I have a bit more time. I also realized, that there might have been a misunderstanding on my part concerning the functionality of rmc. I tried to use it on .rm files of an annotated PDF, not on .rm files of a notebook. And I'm not sure whether that's inside the scope of rmc?

ricklupton commented 1 year ago

It doesn't currently overlay the annotations on top of the original PDF, but the drawing should be stored and converted from the .rm file just the same as if it was a notebook.

Joogle commented 1 year ago

Retried it when trying to build an example to replicate, now seems to work with Remarkable Software Version 3.3.2.1666