Skip to content

Getting "ValueError: invalid literal for int() with base 10" error when access section's margin #1539

@YaroslavDrovolskyi

Description

@YaroslavDrovolskyi

Using python-docx 1.2.0, I get this error when access section.right_margin:

  File "docx\section.py", line 226, in right_margin
  File "docx\oxml\section.py", line 370, in right_margin
  File "docx\oxml\xmlchemy.py", line 193, in get_attr_value
  File "docx\oxml\simpletypes.py", line 27, in from_xml
  File "docx\oxml\simpletypes.py", line 402, in convert_from_xml
ValueError: invalid literal for int() with base 10: '0.218505859375'

Meanwhile, Word's document.xml contains following:

...
<w:sectPr>
    ...
    <w:pgMar w:bottom="0" w:top="1114.400634765625" w:left="0" w:right="0.218505859375" w:header="0" w:footer="720"/>
</w:sectPr>
...

This probles is similar to issues #1335 and #1475 which were resolved.
I would be grateful if you could suggest a solution to get around this. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions