from fpdf import FPDF def capitalize_first_letter(sentence): words = sentence.split() # Split the sentence into words capitalized_words = [word.capitalize() for word in words] # Capitalize each word's first letter return ' '.join(capitalized_words) # Join the words back into a sentence # Example usage: # 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() sentence = label_with_pipeline result = capitalize_first_letter(sentence) # Set font for title pdf.set_font("Arial", size=16, style='B') pdf.cell(200, 10, txt=f"{result} Recipe ", ln=True, align="C") # Add recipe details to PDF pdf.ln(10) # Add some space pdf.set_font("Arial", size=12) # Add the recipe text 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 to a file pdf_output = f"{result} Recipe.pdf" pdf.output(pdf_output) return pdf_output