Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVG clip intersections and operators #9673

Merged
merged 1 commit into from
Apr 22, 2018
Merged

Conversation

janpe2
Copy link
Contributor

@janpe2 janpe2 commented Apr 17, 2018

Fixes #8496

When a new clipping path is set, the result should be the intersection of the new path with the previous clipping path. Currently the SVG backend incorrectly just replaces the previous clipping path with the new one.

SVG can automatically compute the intersection. It's easiest to add a clip-path attribute to a clipPath element. The SVG Recommendation says:

If a valid 'clip-path' reference is placed on a 'clipPath' element, the resulting clipping path is the intersection of the contents of the 'clipPath' element with the referenced clipping path.

In issue #8496 a text-shaped clipping path is first set and then a larger rectangular path. This is repeated in a number of texts on the page.
issue8496_reduced.pdf
The reduced PDF should show a black letter 'a', not a rectangle.

I have also fixed all the painting operators S s f f* B B* b b* n that should generate clipping paths. Previously only n has worked. Here is a file to test these:
clip_operators.pdf

@timvandermeij
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/0d8a525e01333aa/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/0d8a525e01333aa/output.txt

Total script time: 2.38 mins

Published

@timvandermeij
Copy link
Contributor

Moreover, this fixes the majority of #8682 (only some text/images are missing, but all clipping is now correct).

@timvandermeij timvandermeij merged commit c5c06bf into mozilla:master Apr 22, 2018
@timvandermeij
Copy link
Contributor

Good find; thank you for improving this!

movsb pushed a commit to movsb/pdf.js that referenced this pull request Jul 14, 2018
SVG clip intersections and operators
@janpe2 janpe2 deleted the svg-clip branch March 10, 2020 16:55
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.

SVG example generates svg holding lots of small black boxes -> the DOM looks weird.
3 participants