Repository navigation
SVG: support <use> in <clipPath> and <clipPath> outside <defs>, as Illustrator writes them - #2145
Open
RavSinghChandan wants to merge 4 commits into
Open
RavSinghChandan wants to merge 4 commits into
RavSinghChandan wants to merge 4 commits into
Conversation
Collaborator
|
pylint is failint: |
RavSinghChandan
force-pushed
the
svg-clip-path-outside-defs
branch
from
November 10, 2026 04:01
9ae7327 to
78b4437
Compare
Author
|
Thanks, fixed: the concatenated strings in that parametrize list are now in parentheses, and pylint passes on the test file. I also rebased on master. |
andersonhc
reviewed
Nov 10, 2026
|
|
||
| @force_nodocument | ||
| def build_clipping_path(self, shape: "Element", clip_id: Optional[str]) -> None: | ||
| clipping_path_shape = self._clipping_path_shape(shape) |
Collaborator
There was a problem hiding this comment.
When references a , this helper returns a PaintedPath rather than a ClippingPath
RavSinghChandan
force-pushed
the
svg-clip-path-outside-defs
branch
from
November 10, 2026 12:59
78b4437 to
74de58c
Compare
RavSinghChandan
force-pushed
the
svg-clip-path-outside-defs
branch
from
November 10, 2026 14:10
74de58c to
e4717a7
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adobe Illustrator writes every clip path like this, next to the elements it clips rather than in
<defs>:fpdf2 ignores both the
<clipPath>outside<defs>("Ignoring unsupported SVG tag: ") and the<use>inside it ("Ignoring unsupported child tag: "), so the clip path is never registered and every element that uses it fails withKeyError: '#SVGID_2_'. The six file-type icons in PyMuPDF's documentation (docs/images/icons/icon-pdf.svgetc.) all fail this way.<clipPath>found among the children of a group is now handled like one in<defs>(the shared code moved tobuild_clip_path_tag()); it is never rendered directly.<use>in a<clipPath>now adds the shape or path it references, with itsx/yandtransformapplied as SVG specifies (translate(x, y) first, likebuild_xref()does). A<use>that references another<use>or a group is still ignored with a warning: the spec only allows shapes, text and paths there.The six PyMuPDF icons render correctly with this change (checked visually).
Added
test_svg_clip_path_outside_defs,test_svg_clip_path_with_use,test_svg_clip_path_with_use_placementandtest_svg_clip_path_unsupported_child; the first three fail on master, and the new code is fully covered.pytest test/svg test/drawing, black, pylint and mypy pass