From 15af379b69627e1dacd2253d510b32520298964e Mon Sep 17 00:00:00 2001 From: Lucas Cimon <925560+Lucas-C@users.noreply.github.com> Date: Wed, 28 Feb 2024 18:05:53 +0100 Subject: [PATCH] New ul_bullet_color parameter for FPDF.write_html() (#1126) --- CHANGELOG.md | 1 + fpdf/drawing.py | 10 ++++++++++ fpdf/fpdf.py | 1 + fpdf/html.py | 24 +++++++++++------------- test/html/html_ul_bullet_color.pdf | Bin 0 -> 1066 bytes test/html/test_html.py | 20 ++++++++++++++++++++ 6 files changed, 43 insertions(+), 13 deletions(-) create mode 100644 test/html/html_ul_bullet_color.pdf diff --git a/CHANGELOG.md b/CHANGELOG.md index b4f8a4cbd..cada1c04e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ This can also be enabled programmatically with `warnings.simplefilter('default', ## [2.7.9] - Not released yet ### Added * support for overriding paragraph direction on bidirectional text +* new optional `ul_bullet_color` parameter for `FPDF.write_html()` ### Fixed ### Changed diff --git a/fpdf/drawing.py b/fpdf/drawing.py index d81593d47..26d0a8d3d 100644 --- a/fpdf/drawing.py +++ b/fpdf/drawing.py @@ -217,6 +217,11 @@ def colors(self): """The color components as a tuple in order `(r, g, b)` with alpha omitted.""" return self[:-1] + @property + def colors255(self): + "The color components as a tuple in order `(r, g, b)` with alpha omitted, in range 0-255." + return tuple(255 * v for v in self.colors) + def serialize(self) -> str: return " ".join(number_to_str(val) for val in self.colors) + f" {self.OPERATOR}" @@ -260,6 +265,11 @@ def colors(self): """The color components as a tuple in order (g,) with alpha omitted.""" return self[:-1] + @property + def colors255(self): + "The color components as a tuple in order `(r, g, b)` with alpha omitted, in range 0-255." + return tuple(255 * v for v in self.colors) + def serialize(self) -> str: return " ".join(number_to_str(val) for val in self.colors) + f" {self.OPERATOR}" diff --git a/fpdf/fpdf.py b/fpdf/fpdf.py index 0ca1f780f..c6af49f3a 100644 --- a/fpdf/fpdf.py +++ b/fpdf/fpdf.py @@ -405,6 +405,7 @@ def write_html(self, text, *args, **kwargs): dd_tag_indent (int): numeric indentation of
elements table_line_separators (bool): enable horizontal line separators in ul_bullet_char (str): bullet character for
ul_bullet_char (str): bullet character for