from fpdf import FPDF # Function to capitalize the first letter of each word def capitalize_first_letter(sentence): words = sentence.split() return ' '.join([word.capitalize() for word in words]) # Function to generate PDF from recipe details def generate_pdf(recipe_text: str, label_with_pipeline: str): pdf = FPDF() pdf.set_auto_page_break(auto=True, margin=15) pdf.add_page() # Capitalize label for the title result = capitalize_first_letter(label_with_pipeline) # Add Title pdf.set_font("Arial", size=16, style='B') pdf.cell(200, 10, txt=f"{result} Recipe", ln=True, align="C") # Add Recipe Text pdf.ln(10) pdf.set_font("Arial", size=12) pdf.multi_cell(0, 10, txt=recipe_text) # Add Monogram pdf.ln(10) pdf.set_font("Arial", size=10) pdf.cell(200, 10, txt="Developed by M.Nabeel", ln=True, align="C") # Save PDF pdf_output = f"{result} Recipe.pdf" pdf.output(pdf_output) return pdf_output