Skip to content

TypeError in PDF translation: '>=' not supported between instances of 'str' and 'int' #20

Description

@icosane

I'm running into a TypeError when translating certain PDFs. It seems to be triggered by specific pages (likely due to links or metadata), but the rest of the document translates fine if I remove the problematic page.

File "C:\test\.venv\Lib\site-packages\argostranslatefiles\formats\pdf.py", line 18, in translate
    translator.translate_pdf()
  File "C:\test\.venv\Lib\site-packages\argostranslatefiles\formats\pdf.py", line 56, in translate_pdf
    self._apply_translations_to_pdf()
  File "C:\test\.venv\Lib\site-packages\argostranslatefiles\formats\pdf.py", line 200, in _apply_translations_to_pdf
    self._insert_styled_text_blocks(page, normal_blocks, is_bold=False)
  File "C:\test\.venv\Lib\site-packages\argostranslatefiles\formats\pdf.py", line 224, in _insert_styled_text_blocks
    elif link_info.get("page", -1) >= 0:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: '>=' not supported between instances of 'str' and 'int'

Applying this temporary fix allowed the translation to complete:

elif int(link_info.get("page", -1)) >= 0:

I'm opening this as an issue, as I am not certain if this fix will break anything else.

I'm attaching a file that reproduces the issue: bad.pdf

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions