def add_birthday_details(self, name, age, birth_date): self.set_font('Arial', '', 12) self.cell(0, 10, f"To: name", ln=True) self.cell(0, 10, f"Age: age", ln=True) # Birthday countdown today = datetime.now().date() bday = datetime.strptime(birth_date, "%Y-%m-%d").date().replace(year=today.year) if bday < today: bday = bday.replace(year=today.year + 1) days_left = (bday - today).days self.cell(0, 10, f"Days until next birthday: days_left", ln=True) # Zodiac sign (simplified) zodiac = get_zodiac_sign(birth_date) self.cell(0, 10, f"Zodiac: zodiac", ln=True) self.ln(10)
def add_messages_section(self, messages): self.set_font('Arial', 'B', 12) self.cell(0, 10, "💬 Messages from Friends:", ln=True) self.set_font('Arial', '', 11) for msg in messages: self.cell(0, 6, f"✉️ msg", ln=True) self.ln(10) birthday pdf
for date, sign in signs.items(): if month_day <= date: return sign return "Capricorn" pdf = BirthdayPDF() pdf.add_page() pdf.add_birthday_details("Alex", 28, "1996-05-15") pdf.add_memory_section(["Beach trip 2023", "Surprise party 2022", "Concert night 2021"]) pdf.add_messages_section(["Happy birthday, legend! 🚀", "Cheers to another year!", "You rock, Alex!"]) pdf.add_qr_code("https://example.com/birthday-video") pdf.add_party_checklist() pdf.output("Birthday_Alex.pdf") print("✅ Birthday PDF generated: Birthday_Alex.pdf") 🔧 Useful Features You Can Add: | Feature | Benefit | |--------|---------| | 🖼️ Auto-insert age + photo collage | Visual keepsake | | 🎵 Spotify playlist QR code | Interactive gift | | 🗓️ Countdown timer to next birthday | Builds anticipation | | ✍️ Handwritten font for messages | Personal touch | | 🎈 Balloon/confetti design themes | Festive look | | 📤 Email PDF automatically | Easy sharing | | 🎁 Gift suggestion list (based on age/interests) | Helpful for guests | | 🌍 Multilingual support | For international friends | def add_birthday_details(self, name, age, birth_date): self
def add_memory_section(self, memories): self.set_font('Arial', 'B', 12) self.cell(0, 10, "📸 Birthday Memories:", ln=True) self.set_font('Arial', '', 11) for memory in memories: self.cell(0, 6, f"• memory", ln=True) self.ln(10) "%Y-%m-%d").date().replace(year=today.year) if bday <
def add_party_checklist(self): self.set_font('Arial', 'B', 12) self.cell(0, 10, "🎉 Party Checklist:", ln=True) self.set_font('Arial', '', 11) items = ["🎈 Balloons", "🎂 Cake", "📸 Camera", "🎵 Playlist", "🎁 Gifts", "🍕 Snacks"] for item in items: self.cell(0, 6, f"☐ item", ln=True) def get_zodiac_sign(birth_date): # Simplified zodiac mapping month_day = datetime.strptime(birth_date, "%Y-%m-%d").strftime("%m-%d") signs = "03-21":"Aries","04-20":"Taurus","05-21":"Gemini","06-21":"Cancer","07-23":"Leo","08-23":"Virgo", "09-23":"Libra","10-23":"Scorpio","11-22":"Sagittarius","12-22":"Capricorn","01-20":"Aquarius","02-19":"Pisces"
def add_qr_code(self, video_link): img = qrcode.make(video_link) img.save("qr_temp.png") self.image("qr_temp.png", x=150, y=80, w=40) self.set_xy(10, self.get_y()) self.cell(0, 10, "🎥 Scan QR code for a video wish!", ln=True)