Skip to content

Feature: SVG optimization#1350

Merged
Lucas-C merged 3 commits intopy-pdf:masterfrom
petri-lipponen-movesense:feature/svg_optimization
Jan 17, 2025
Merged

Feature: SVG optimization#1350
Lucas-C merged 3 commits intopy-pdf:masterfrom
petri-lipponen-movesense:feature/svg_optimization

Conversation

@petri-lipponen-movesense
Copy link
Copy Markdown

  • Optimized svg image rendering by avoiding deepcopy (uses copy=False flag when calling add_item in svg.build_group where item is known to be not re-used). This reduces time to render SVG's by 50%-70%.

Checklist:

  • A unit test is covering the code added / modified by this PR. N/A

  • This PR is ready to be merged

  • In case of a new feature, docstrings have been added, with also some documentation in the docs/ folder N/A

  • A mention of the change is present in CHANGELOG.md

By submitting this pull request, I confirm that my contribution is made under the terms of the GNU LGPL 3.0 license.

- Use copy=False flag when calling add_item in svg.build_group
@petri-lipponen-movesense
Copy link
Copy Markdown
Author

I'm sure there are other parts of the SVG handling that can help, but this seemed to be the low hanging fruit. In my case it dropped ~100 page PDF generation from 27 minutes to 13...

@Lucas-C
Copy link
Copy Markdown
Member

Lucas-C commented Jan 17, 2025

@allcontributors please add @petri-lipponen-movesense for code

@allcontributors
Copy link
Copy Markdown

@Lucas-C

I've put up a pull request to add @petri-lipponen-movesense! 🎉

@Lucas-C
Copy link
Copy Markdown
Member

Lucas-C commented Jan 17, 2025

Wow, thank you very much @petri-lipponen-movesense! 👍

Excellent job, thank you very much for this contribution ❤️

@Lucas-C Lucas-C merged commit b366272 into py-pdf:master Jan 17, 2025
@petri-lipponen-movesense petri-lipponen-movesense deleted the feature/svg_optimization branch January 20, 2025 06:38
@Lucas-C
Copy link
Copy Markdown
Member

Lucas-C commented Apr 23, 2025

This has been released in https://github.com/py-pdf/fpdf2/releases/tag/2.8.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants