i want to make pdf using python(jupyter) in this i want to create 2 partition left side & right side but when i create 2 partition on the basis of column_width, & write the content on each side it was showing all content on left side overlap the right side content.
Here’s the code.
pdf = FPDF()
pdf.add_page()
pdf.set_font("Arial", 'B', size=16)
pdf.cell(200, 10, txt="Fact Sheet", ln=True, align='C')
column_width = (pdf.w - 30) / 2
pdf.set_xy(10, 30)
pdf.set_font("Arial", 'B', size=12)
pdf.cell(column_width, 10, txt="Fund Objective", ln=1)
pdf.set_font("Arial", size=8)
left_column_text = "The investment objective"
pdf.multi_cell(column_width, 10, txt=normalize_text(left_column_text))
right_column = 10 + column_width +10
pdf.set_xy(right_column, 30)
pdf.set_font("Arial", 'B', size=12)
pdf.cell(column_width, 10, txt="Fund Information", ln=1)
pdf.set_font("Arial", size=8)
right_column_text = "With over 15 years of experience in managing investments in the stock market."
pdf.multi_cell(column_width, 10, txt=normalize_text(right_column_text))
I have try by finding the width & height of right column by using:
print(f'PDF dimensions: {pdf.w} mm wide by {pdf.h} mm high')
print(f"Column width: {column_width} mm")
print(f"Left Column starts at X=10 mm, Right Column starts at X={right_column} mm")
and it was come right.
output
PDF dimensions: 210.0015555555555 mm wide by 297.0000833333333 mm high
Column width: 90.00077777777776 mm
Left Column starts at X=10 mm, Right Column starts at X=110.00077777777776 mm
i don’t know where is the problem
Rick Dutta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.