Skip to content

Commit

Permalink
Feature: SVG optimization (#1350)
Browse files Browse the repository at this point in the history
Co-authored-by: Lucas Cimon <[email protected]>
  • Loading branch information
petri-lipponen-movesense and Lucas-C authored Jan 17, 2025
1 parent cdf981f commit b366272
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ This can also be enabled programmatically with `warnings.simplefilter('default',
### Added
* support for [shading patterns (gradients)](https://py-pdf.github.io/fpdf2/Patterns.html)
* support for strikethrough text
* Improved SVG image speed by 50% to 70% - thanks to @petri-lipponen-movesense - [PR #1350](https://github.com/py-pdf/fpdf2/pull/1350)
### Fixed
* [`FPDF.write_html()`](https://py-pdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.write_html): Fixed rendering of content following `<a>` tags; now correctly resets emphasis style post `</a>` tag: hyperlink styling contained within the tag authority. - [Issue #1311](https://github.com/py-pdf/fpdf2/issues/1311)

Expand Down
10 changes: 5 additions & 5 deletions fpdf/svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,15 +917,15 @@ def build_group(self, group, pdf_group=None):
if child.tag in xmlns_lookup("svg", "defs"):
self.handle_defs(child)
elif child.tag in xmlns_lookup("svg", "g"):
pdf_group.add_item(self.build_group(child))
pdf_group.add_item(self.build_group(child), False)
elif child.tag in xmlns_lookup("svg", "path"):
pdf_group.add_item(self.build_path(child))
pdf_group.add_item(self.build_path(child), False)
elif child.tag in shape_tags:
pdf_group.add_item(self.build_shape(child))
pdf_group.add_item(self.build_shape(child), False)
elif child.tag in xmlns_lookup("svg", "use"):
pdf_group.add_item(self.build_xref(child))
pdf_group.add_item(self.build_xref(child), False)
elif child.tag in xmlns_lookup("svg", "image"):
pdf_group.add_item(self.build_image(child))
pdf_group.add_item(self.build_image(child), False)
else:
LOGGER.warning(
"Ignoring unsupported SVG tag: <%s> (contributions are welcome to add support for it)",
Expand Down

0 comments on commit b366272

Please sign in to comment.