0

My python code automates the process of replacing the Job Role and Hiring Manager for a cover letter.

The code works but it makes the document's formatting all wonky. For context, my cover letter includes images and lines and the code moves all of them from their original position.

Dictionary = {"Hiring Manager": hiringManager, "Job_Role": jobRole} 
for i in Dictionary:
    for p in document.paragraphs:
        if p.text.find(i) >= 0:
            p.text = p.text.replace(i, Dictionary[i])
for p in document.paragraphs:
    p.style = document.styles['Normal']
    for run in p.runs:
        run.font.size = Pt(10.5)
        run.font.name = 'Calibri'

savedFile = location + saveText + ' - ' + jobRole + ".docx" #File name and location
document.save(savedFile)   
convert(savedFile) #Convert into PDF using docxtopdf
user209835
  • 13
  • 4

0 Answers0