Last active
September 13, 2024 20:12
-
-
Save aspose-com-kb/4cab4e940cfacd33de378d44da8ea1f9 to your computer and use it in GitHub Desktop.
Paragraph Formatting in Word with Python. For more details: https://kb.aspose.com/words/python/paragraph-formatting-in-word-with-python/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import aspose.words as aw | |
import aspose.pydrawing as drawing | |
# Load the license | |
wordLic = aw.License() | |
wordLic.set_license("license.lic") | |
newDoc = aw.Document() | |
builder = aw.DocumentBuilder(newDoc) | |
# Set formatting | |
paragraphFormat = builder.paragraph_format | |
paragraphFormat.alignment = aw.ParagraphAlignment.JUSTIFY | |
paragraphFormat.left_indent = 45 | |
paragraphFormat.right_indent = 45 | |
paragraphFormat.space_after = 20 | |
paragraphFormat.borders.horizontal.line_style = aw.LineStyle.DOUBLE | |
paragraphFormat.style.font.size = 12 | |
paragraphFormat.style.font.bold = True | |
paragraphFormat.style.font.color = drawing.Color.blue | |
# Output text | |
builder.writeln("Word paragraph formatting refers to adjusting the appearance and layout of paragraphs in a document to improve readability and presentation.") | |
builder.writeln("Word also provides options to control spacing before and after paragraphs, which helps in creating visually appealing documents with clear structure.") | |
newDoc.save("Formatted.docx") | |
print ("Text formatted") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment