# Tambahan pembersihan untuk semua karakter spesial yang tidak bisa di-encode ke latin-1
def fully_sanitize_text(text):
text = re.sub(r'[–—]', '-', text) # Ganti em dash
text = text.replace("…", "...") # Ganti ellipsis
text = text.encode("ascii", "ignore").decode() # Hapus karakter non-ascii
return text
# Terapkan ke semua item checklist
checklist_data_cleaned = {
title: [fully_sanitize_text(item) for item in items]
for title, items in checklist_data.items()
}
# Buat ulang PDF dengan teks yang sudah dibersihkan
pdf = PDF()
pdf.add_page()
for title, items in checklist_data_cleaned.items():
pdf.chapter_title(title)
for item in items:
pdf.chapter_body(f"- {item}")
# Simpan PDF
output_path = "/mnt/data/Checklist_Mancing_Anti_Mabuk_Laut.pdf"
pdf.output(output_path)
output_path