Skip to content

Commit

Permalink
Fix ugly rotation of text with line breaks
Browse files Browse the repository at this point in the history
  • Loading branch information
bastienlc committed Apr 25, 2024
1 parent f982814 commit b996047
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/pdf_watermark/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ def draw_centered_string_with_line_breaks(
text: str,
):
text_lines = text.split(r"\n")
line_height = (
watermark._leading
) # line height is set when setting the font of the canvas
y += (len(text_lines) - 1) * line_height / 2 # also center the text vertically
for line in text_lines:
watermark.drawCentredString(x, y, line)
y -= (
watermark._leading
) # line spacing is set when setting the font of the canvas
y -= watermark._leading


def change_base(x: float, y: float, rotation_matrix: np.ndarray) -> Tuple[float, float]:
Expand Down
Binary file modified tests/fixtures/2.pdf
Binary file not shown.
Binary file modified tests/fixtures/3.pdf
Binary file not shown.

0 comments on commit b996047

Please sign in to comment.