Last active
January 27, 2024 04:28
-
-
Save aspose-com-kb/2dc01b68804561383d844ef164bac4b9 to your computer and use it in GitHub Desktop.
Convert Paragraph into Bullet Points in Word using Python. For more details: https://kb.aspose.com/words/python/convert-paragraph-into-bullet-points-in-word-using-python/
This file contains hidden or 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 re | |
import aspose.words as aw | |
from typing import cast | |
# Path to the source files | |
filePath = "c://word//" | |
# Load the Aspose.Words license in your application to remove bullets | |
aw.License().set_license(filePath + "Conholdate.Total.Product.Family.lic") | |
# Instantiate the Document class object to load the source word | |
srcDoc = aw.Document(filePath + "out.docx") | |
text = srcDoc.to_string(aw.SaveFormat.TEXT) | |
pattern = "(?<=[.!?])\s+" | |
sentences = re.split(text, pattern) | |
output = aw.Document() | |
builder = aw.DocumentBuilder(output) | |
builder.font.bold = True | |
builder.font.name = "Courier" | |
builder.font.size = 12 | |
builder.list_format.list = output.lists.add(aw.lists.ListTemplate.BULLET_SQUARE) | |
for sentence in sentences: | |
builder.writeln(sentence.strip()) | |
builder.list_format.remove_numbers() | |
output.save("bullet-sample.docx") | |
print ("Bullets added successfully") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment