In Microsoft Word, if you press “return” between paragraphs, there would be an empty paragraph in between, and you can select the “return” to change the font size to make the empty line look higher or lower. So, is there a way to read the font size of that empty line with python?
ps. the empty paragraph is within a table cell.
a snippet of the table I’m trying to read
I’ve learnt that I can get the font size of normal text in table cell using the follow code:
for cell in column.cells:
for paragraph in cell.paragraphs:
if paragraph.text == "":
print(font size of the empty line)
for run in paragraph.runs:
font_size = run.font.size #output font size of non-empty text
But the problem is, empty paragraph have empty string as paragraph.text, hence there would be no “run” for it.
In this screenshot, 3 smaller returns have the same height as 2 bigger returns, and by accessing the font size of the return, I can figure out the total height of empty space above the text.
On the place of print(font size of the empty line)
I’ve tried paragraph.style.font.size
, paragraph.style.base_style
, paragraph.text.format
but none returned the right result.
I can see the exact font size of the empty line in Word Styles gallery, but just don’t know how to read it with python.
parase is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.