pythonms-worddocxpython-docx

python-docx, access to paragraph font-size


I want to access to a paragraph or run that has a unique font or font-size using python-docx. How i can get texts of runs or paragraphs that has specified font or font-size?


Solution

  • For any one that want to know:

    for paragraph in doc.paragraphs:
        for run in paragraph.runs:
            if run.font.size == Pt(16):
                print(paragraph.text)