Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

basepage.CropBox or basepage.MediaBox or basepage.Parent.MediaBox returns None #11

Open
flomlo opened this issue Aug 20, 2021 · 2 comments

Comments

@flomlo
Copy link

flomlo commented Aug 20, 2021

Hi,

the renderer crashes when used on the supplied buggy.zip (called via python -m rmrl buggy.zip ) resulting in the following error:

Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/florian/.local/lib/python3.9/site-packages/rmrl/__main__.py", line 53, in <module>
    sys.exit(main())
  File "/home/florian/.local/lib/python3.9/site-packages/rmrl/__main__.py", line 44, in main
    stream = render(source,
  File "/home/florian/.local/lib/python3.9/site-packages/rmrl/render.py", line 149, in render
    merge_pages(basepage, rmpage, i in changed_pages, expand_pages)
  File "/home/florian/.local/lib/python3.9/site-packages/rmrl/render.py", line 442, in merge_pages
    bpage_box = list(map(float, basepage.CropBox
TypeError: 'NoneType' object is not iterable

Apparently, in this particular case, neither basepage.CropBox, nor basepage.MediaBox nor basepage.parent.CropBox exist.

I'm trying to debug it myself, but am not particularly confident right now. Could you provide me some hints?

Thank you very much :)

@flomlo
Copy link
Author

flomlo commented Aug 20, 2021

I'm the author of this particular .pdf, maybe I accidentally fucked up some LuaLaTex stuff and made the resulting .pdf very weird. Feel free to request modified versions if it helps with the debugging.

Oh, for most of my ~300 other files on my remarkable it runs totally fine.

@flomlo
Copy link
Author

flomlo commented Aug 20, 2021

if I understand the comment above

bpage_box = list(map(float, basepage.CropBox
correctly then we need to load CropBox if existent, otherwise MediaBox.

I would suggest the following fix:

    bpage_box = list(map(float, basepage.inheritable.CropBox
                                or basepage.inheritable.MediaBox))

This seems to work fine on my ~300 files.

I'll generate a pull request if you think this is a valid replacement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant