I have few text documents in a folder and would like to convert them to PDF Format. I am able to do it individually with the below code. Is there any way to select all the text files from a folder, convert and save them with the original name (as it was for text documents)? Below is the code I used to convert each file:
from fpdf import FPDF
pdf = FPDF()
pdf.add_page()
pdf.set_font("Arial", size = 8)
f = open("C:\\Users\\rc06587\\Desktop\\Text Doc\\Sample\\New folder (2)\\exp_000004593_cn23rk__09042020000000_citrixsystemsinc_92080217mr_00384.TXT", "r")
for x in f:
pdf.cell(10, 4, txt = x, ln = 1, align = 'L')
pdf.output("exp_000004593_cn23rk__09042020000000_citrixsystemsinc_92080217mr_00384.TXT.pdf")