I have a series of rtf files that I want to adjust the formatting of. The files use a variety of fonts, text sizes, and formatting. I want to standardize them to use 12 pt bold Arial font with no italics and 0pt line spacing. I do want to keep the existing colors and bullet points though. The files have to be .rtf because they're used in a program that requires that format.
Most of my searches have pointed me to PyRTF3. However, I have been unable to find any kind of documentation on it. I'm not really sure how to approach it.
I've tried using striprtf, but the problem is that it removes the formatting like colors and bullet points, which I need to keep. I got close by combining it with this solution, but the files have a watermark and again, no colors or bullet points.
from striprtf.striprtf import rtf_to_text
import aspose.words as aw
rtfPath = "path/to/file.rtf"
rtfLines = []
with open(rtfPath, "r") as file:
for line in file:
rtfLines.append(rtf_to_text(line))
newdoc = aw.Document()
builder = aw.DocumentBuilder(newdoc)
font = builder.font
font.bold = True
font.name = "Arial"
font.size = 12
paragraphFormat = builder.paragraph_format
paragraphFormat.alignment = aw.ParagraphAlignment.JUSTIFY
paragraphFormat.keep_together = True
for line in rtfLines:
builder.writeln(line.rstrip("\n"))
newdoc.save(rtfPath)