Skip to content

FPDF.rect: graphics issues with round corners #1632

@alhman

Description

@alhman

When rendering a rect with round corners some graphics issues are visible. See attached pdf at the end.

  1. if the border is thicker the inner and outer circles of the corners are not positioned correctly.

  2. if there is a background color a small line is visible for each corner.

sample code to generade pdf:

from fpdf import FPDF

if __name__ == "__main__":
    pdf = FPDF()
    pdf.add_page()

    pdf.set_draw_color(0, 0, 0)
    pdf.set_fill_color(255, 255, 255)
    pdf.set_line_width(6)
    pdf.rect(50, 40, 120, 70, style='DF', round_corners=True, corner_radius=12)
    pdf.set_fill_color(230, 120, 125)
    pdf.set_line_width(1)
    pdf.rect(50, 160, 120, 70, style='DF', round_corners=True, corner_radius=12)
    pdf.output("round_corners.pdf")

round_corners.pdf

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions