Untitled
unknown
plain_text
a month ago
2.7 kB
3
Indexable
from fpdf import FPDF import random # List of 100 Sikh Quotes (Gurmukhi, Romanized, English) sikh_quotes = [ ("ਨਾਨਕ ਦੁਖੀਆ ਸਭੁ ਸੰਸਾਰੁ ॥", "Nānak ḏukẖīā sabẖ sansār.", "O Nanak, the whole world is suffering."), ("ਵਾਹਿਗੁਰੂ ਜੀ ਕਾ ਖਾਲਸਾ, ਵਾਹਿਗੁਰੂ ਜੀ ਕੀ ਫਤਹਿ ॥", "Wāhigurū jī kā Khālsā, Wāhigurū jī kī fateh.", "The Khalsa belongs to Waheguru, and victory belongs to Waheguru."), ("ਹਉਮੈ ਨਵੈ ਖਾਇ ਗਇਆ ॥", "Haumai nawai khāe gaiā.", "Ego consumes the new knowledge."), # Add more quotes to reach 100 ] # List of reflection questions reflection_questions = [ "What is one thing you are grateful for today?", "How do you find peace in difficult situations?", "What is one step you can take towards your goals?", "How does this quote relate to your life today?", # Add more to cover all 100 pages ] # List of available designs designs = ["khanda.png", "floral.png", "dolphin.png", "squirrel.png", "mountains.png", "river.png"] # Initialize PDF pdf = FPDF() pdf.set_auto_page_break(auto=True, margin=15) # Add font for Unicode support (Ensure you have DejaVu Sans installed) pdf.add_font("DejaVu", "", "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", uni=True) # Generate 100 pages for i in range(100): pdf.add_page() # Select a random quote quote_gurmukhi, quote_romanized, quote_english = random.choice(sikh_quotes) # Select a random design design_image = f"images/{random.choice(designs)}" # Add title pdf.set_font("DejaVu", "", 16) pdf.cell(200, 10, f"Page {i+1} - Sikh Inspirational Journal", ln=True, align='C') pdf.ln(10) # Add Quote pdf.set_font("DejaVu", "", 14) pdf.multi_cell(0, 10, quote_gurmukhi, align="C") pdf.ln(5) pdf.set_font("DejaVu", "", 12) pdf.multi_cell(0, 10, quote_romanized, align="C") pdf.ln(5) pdf.multi_cell(0, 10, quote_english, align="C") pdf.ln(10) # Add a reflection question question = random.choice(reflection_questions) pdf.set_font("DejaVu", "", 12) pdf.multi_cell(0, 8, f"🖋 Reflection: {question}", align="L") pdf.ln(5) # Space for writing pdf.cell(0, 10, " ", border=1, ln=True, align='C') pdf.ln(5) pdf.cell(0, 10, " ", border=1, ln=True, align='C') # Add Design in Alternate Corners try: pdf.image(design_image, x=random.choice([10, 150]), y=random.choice([230, 20]), w=40) except: pass # If the image is missing, continue # Save the final PDF pdf.output("Sikh_Inspirational_Journal.pdf") print("PDF generated successfully: Sikh_Inspirational_Journal.pdf")
Editor is loading...
Leave a Comment