Skip to content

Why some words break in the middle #1158

@xin-kevin

Description

@xin-kevin

Hi,
I use the following code snippet to receive the font of words in a word file:

from docx import Document
document = Document('Test_Word.docx')
for paragraph in document.paragraphs:
for run in paragraph.runs:
if run.font:
print ('\n')
print (run.font.name)
print (run.text)

Sorry, I don't know why the code snippet lost the indentation.
In the output, some words break in the middle, for example:

Courier New
u

Courier New
ri

In the example above, 'uri' breaks into 'u' and 'ri'.

Could you please help prevent a word from breaking?

I also attached this word file.
Test_Word.docx

Any comment would be appreciated!

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