

- #HOW DO I DECREASE THE SPACING BETWEEN LINES IN WORD CODE#
- #HOW DO I DECREASE THE SPACING BETWEEN LINES IN WORD MAC#
# no need to set space_after because there is no text after this Paragraph.paragraph_format.space_after = Pt(5) Paragraph.paragraph_format.space_before = Pt(3) Secondly, make sure to apply your formatting to all paragraphs and not just that final one: from docx import Document
#HOW DO I DECREASE THE SPACING BETWEEN LINES IN WORD CODE#
So python-docx is working correctly, and if your output is wrong then it's because your code is wrong.įirst off, I'd strongly advise not to set your line spacing to 3 pt I assume you got confused because it 'didn't work' and you intended to set space_before instead. That last paragraph – the only one you apply your formatting to – has a line spacing of 3pt and 5 pts of space after all other paragraphs appear with default formatting. If you check the generated Word file, you can see your code worked precisely the way you stated. Paragraph_format = paragraph.paragraph_format Paragraph = document.add_paragraph('SPACING BETWEEN EACH SHOULD BE DECREASED')

Paragraph = document.add_paragraph('THIS IS SECOND PARAGRAPH') Paragraph = document.add_paragraph('THIS IS MY FIRST PARAGRAPH ') from docx import Documentįrom import WD_STYLE_TYPEĭocument.add_heading('THIS IS MY HEADER WANT TO UNDERLINE IT') Is there a way to change (decrease) this spacing Tried selecting the line (cannot) and its paragraph mark but that had no effect.
#HOW DO I DECREASE THE SPACING BETWEEN LINES IN WORD MAC#
I need your assistances to decrease the spacing between the paragraphs through python but not setting it via word file. Running Word 2008 Mac under OS 10.5.8 (PPC): By default, Word puts a large space between the footnote separator line and the first footnote. I found some examples here link 1 and link 2which but don't understand the xml part to achieve desired results. Am trying to decrease spacing between paragraph with the code below in python-docx but when apply the the formatting to the paragraph the last paragraph shrinks but the line between the paragraphs doesn't decrease.
