|
from fpdf import FPDF
|
|
|
|
|
|
def capitalize_first_letter(sentence):
|
|
words = sentence.split()
|
|
capitalized_words = [word.capitalize() for word in words]
|
|
return ' '.join(capitalized_words)
|
|
|
|
|
|
|
|
def generate_pdf(recipe_text: str, label_with_pipeline: str):
|
|
pdf = FPDF()
|
|
pdf.set_auto_page_break(auto=True, margin=15)
|
|
pdf.add_page()
|
|
|
|
sentence = label_with_pipeline
|
|
result = capitalize_first_letter(sentence)
|
|
|
|
|
|
pdf.set_font("Arial", size=16, style='B')
|
|
pdf.cell(200, 10, txt=f"{result} Recipe ", ln=True, align="C")
|
|
|
|
|
|
pdf.ln(10)
|
|
pdf.set_font("Arial", size=12)
|
|
|
|
|
|
pdf.multi_cell(0, 10, txt=recipe_text)
|
|
|
|
|
|
pdf.ln(10)
|
|
pdf.set_font("Arial", size=10)
|
|
pdf.cell(200, 10, txt="Developed by M. Nabeel", ln=True, align="C")
|
|
|
|
|
|
|
|
|
|
pdf_output = f"{result} Recipe.pdf"
|
|
pdf.output(pdf_output)
|
|
|
|
return pdf_output
|
|
|