# আবার try করছি, সব স্পেশাল ক্যারেক্টার বাদ দিয়ে plain text দিয়ে। def clean_text_v2(text): # Replace curly quotes and special chars with simple ones and remove ellipsis replacements = { "“": '"', "”": '"', "‘": "'", "’": "'", "•": "-", "⬇️": "↓", "✨": "*", "🔥": "*", "💡": "(lightbulb)", "👇": "(down)", "☕️": "(coffee)", "😎": "(cool)", "📈": "(chart up)", "💰": "(money)", "👀": "(eyes)", "😴": "(sleepy)", "⬇": "↓", "…": "...", # ellipsis replaced with three dots "—": "-", "\u2026": "...", } for k, v in replacements.items(): text = text.replace(k, v) return text pdf = PDF() pdf.set_auto_page_break(auto=True, margin=15) pdf.add_page() pdf.set_font("Arial", "B", 14) pdf.cell(0, 10, "Introduction & How to Use", 0, 1) pdf.set_font("Arial", "", 12) pdf.multi_cell(0, 8, clean_text_v2(intro_text)) pdf.ln(8) pdf.set_font("Arial", "B", 14) pdf.cell(0, 10, "50 Viral Instagram Caption Prompts + Examples", 0, 1) pdf.set_font("Arial", "", 11) for i, (prompt, example) in enumerate(prompts, 1): pdf.multi_cell(0, 7, f"{i}. Prompt: {clean_text_v2(prompt)}") pdf.set_font("Arial", "I", 11) pdf.multi_cell(0, 7, f" Example: {clean_text_v2(example)}") pdf.ln(2) pdf.set_font("Arial", "", 11) pdf.add_page() pdf.set_font("Arial", "B", 14) pdf.cell(0, 10, "Caption Template (Fill-in-the-blank)", 0, 1) pdf.set_font("Arial", "", 12) pdf.multi_cell(0, 8, clean_text_v2(template_text)) pdf.ln(10) pdf.set_font("Arial", "B", 14) pdf.cell(0, 10, "Caption Writing Tips & CTA Guide", 0, 1) pdf.set_font("Arial", "", 12) pdf.multi_cell(0, 8, clean_text_v2(tips)) pdf.output("/mnt/data/Viral_Instagram_Caption_Prompts.pdf")
Similar Videos

0 comments: