from fpdf import FPDF
def create_rich_text_pdf(filename, doc_number):
pdf = FPDF()
pdf.set_auto_page_break(auto=True, margin=15)
# Content to simulate rich text
lorem_ipsum = (
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
"Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "
"Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris "
"nisi ut aliquip ex ea commodo consequat. "
)
# Create 6 Pages
for page_num in range(1, 7):
pdf.add_page()
# 1. Main Header (Bold, Large)
pdf.set_font("Arial", "B", 24)
[Link](0, 20, f"Document #{doc_number}: Page {page_num}", ln=True, align='C')
# 2. Subheader (Italic)
pdf.set_font("Arial", "I", 14)
pdf.set_text_color(100, 100, 100) # Grey color
[Link](0, 10, "Section 1: Introduction to Rich Text", ln=True)
# 3. Standard Paragraph
pdf.set_text_color(0, 0, 0) # Reset to black
pdf.set_font("Arial", "", 12)
pdf.multi_cell(0, 10, lorem_ipsum * 3)
[Link](10)
# 4. Bulleted List Simulation
pdf.set_font("Arial", "B", 12)
[Link](0, 10, "Key Points:", ln=True)
pdf.set_font("Arial", "", 12)
for i in range(1, 4):
[Link](10, 10, f"-", align='R')
[Link](0, 10, f"Important point number {i} regarding this topic.", ln=True)
[Link](10)
# 5. Footer Text
pdf.set_font("Courier", "I", 10)
pdf.multi_cell(0, 10, "Note: This document was generated automatically to simulate a 6-page rich text
format.")
[Link](filename)
# Loop to generate 5 separate files
for i in range(1, 6):
filename = f"Generated_Report_{i}.pdf"
create_rich_text_pdf(filename, i)
print(f"Successfully created: {filename}")