TCPDF icon indicating copy to clipboard operation
TCPDF copied to clipboard

Fixes: missing functionality for svg <use> elements

Open plsnk opened this issue 1 year ago • 3 comments

Fixes: #652

plsnk avatar Oct 09 '23 08:10 plsnk

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
16 out of 17 committers have signed the CLA.

:white_check_mark: johnson361
:white_check_mark: kosmro
:white_check_mark: rubo77
:white_check_mark: bruno-farias
:white_check_mark: ren1244
:white_check_mark: littlepackage
:white_check_mark: theonlytruth
:white_check_mark: remicollet
:white_check_mark: d-salerno
:white_check_mark: simonbuehler
:white_check_mark: mvorisek
:white_check_mark: nicolaasuni
:white_check_mark: williamdes
:white_check_mark: fisharebest
:white_check_mark: plsnk
:white_check_mark: survik1
:x: Nicole Krämer


Nicole Krämer seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant avatar Oct 09 '23 08:10 CLAassistant

Hi, There are still a few problems with this patch applied. The <use> element is more complicated than implemented by this patch. I have a problem file that shows the issue(s) (a cooked down test version from the original shown below). There are three clipPath scenarios that I tested.

  • First is <use> in the <defs><clipPath> section with a forward reference to a path later on in the document. This scenario fails completely and no clipPath is applied.
  • Second is a copied version of the document's <path> in the <defs><clipPath> section, but it retained the original transformation attribute from the source. This scenario failed to apply the transformation.
  • Third is a working version, where the path is normalized.

The used svg (inkscape displays all three version correct): <svg id="testUseClippath" width="100%" height="100%" viewBox="0 0 50 30" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <defs> <clipPath id="usepath"><use xlink:href="#realpath" /></clipPath> <!-- <clipPath id="usepath"><path id="realpath" d="M 14,-1 C 10,1 6,9 0,9 C -6,9 -12,1 -14,-1 C -11,-2 -6,-9 0,-9 C 6,-9 11,-2 14,-1 Z" transform="translate(25,15)" /></clipPath> --> <!-- <clipPath id="usepath"><path d="M 39,14 C 35,16 31,24 25,24 C 19,24 13,16 11,14 C 14,13 19,6 25,6 C 31,6 36,13 39,14 Z" /></clipPath> --> </defs> <g> <rect x="0.1" y="0.1" width="49.8" height="29.8" style="fill:none;stroke:#cc0;stroke-width:0.2" /> <g clip-path="url(#usepath)"> <rect x="0" y="0" width="50" height="30" style="fill:#222;stroke:none" /> <ellipse cx="25" cy="25" rx="15" ry="10" style="fill:#800f08;stroke:none" /> </g> <path id="realpath" d="M 14,-1 C 10,1 6,9 0,9 C -6,9 -12,1 -14,-1 C -11,-2 -6,-9 0,-9 C 6,-9 11,-2 14,-1 Z" transform="translate(25,15)" style="fill:none;stroke:black;stroke-width:1" /> </g> </svg>

BsAtHome avatar Feb 26 '24 12:02 BsAtHome

Please try to resolve the conflicts.

nicolaasuni avatar Apr 20 '24 17:04 nicolaasuni