File size: 1,042 Bytes
dd5ae0f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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