I am making a calendar app using Tkinter in Python3 and I have a problem with the .txt to .pdf conversion.
My code saves user tasks to a .txt file and then can convert this .txt file to a pdf with the press of a button.
If the user creates a pdf with the tasks contained in the .txt file, then changes the .txt file and converts it to a pdf again, it will always convert the contents of the previous saved .txt file.
The only solution is to restart the whole program but I don't want that.
What can I change in my code so every time I change the .txt contents the pdf file contains the upgraded .txt file contents?
I will share the create pdf function below.
#function to create pdf
def PDFCreate():
pdf.set_font("Impact", size=15)
with open("FoundTasks.txt", "r", encoding = 'utf-8') as PDFTasks:
content = PDFTasks.read()
pdf.multi_cell(0, 10, txt=content, align='C')
# create or overwrite the tasks.pdf file with the contents of FoundTasks.txt
pdf.output("Tasks.pdf")