Skip to content

SVG: do not draw an element with display="none" - #2158

Open
RavSinghChandan wants to merge 1 commit into
py-pdf:masterfrom
RavSinghChandan:svg-display-none
Open

RavSinghChandan wants to merge 1 commit into
py-pdf:masterfrom
RavSinghChandan:svg-display-none

Conversation

@RavSinghChandan

Copy link
Copy Markdown

Elements and groups with display="none" are drawn. Inkscape stores hidden layers as <g style="display:none">, and other editors write display="none" on hidden objects, so content the author hid ends up in the PDF. tox's logo (docs/_static/img/tox.svg) has a hidden layer, and optax's favicon (docs/images/favicon.svg) has a hidden group of construction strokes, which are written into the PDF (146 kB with them, 118 kB without).

_build_group_child() now reads display (attribute, style or CSS class) and builds a hidden element into a throwaway group, so it is not drawn, but its ids are still registered and a <use> of an element inside it still works.

Added test_svg_display_none (attribute, hidden Inkscape layer, CSS class) and test_svg_display_none_referenced; the first fails on master. The full test suite passes except test_image_with_explicit_dimensions, which also fails on master in my environment; black, pylint, mypy and pyright pass

This branch has not been deployed

No deployments
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.

1 participant