Add option to force xlink:href when adding logos in svg #255
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.
This PR is kind of a bugfix, kind of an enhancement.
Background:
In #173 the functionality to add a logo in svg qr codes was added. The
xlink:href
attribute was used to add the embedded image (see SvgWriter.php#L53).But
SimpleXML
turns thexlink:href
attribute into ahref
attribute, as this blog post from 10 years ago(!) already stated. So far so good, because in SVGxlink:href
is actually deprecated.Yet there is a catch: If you put an svg-qrcode with an embedded logo into a pdf, the
xlink:href
attribute is still expected. Otherwise the logo simply does not show, just the normal qr code. We could confirm this issue with current versions of PrinceXML and TCPDF in this issue over at our library.What this pr does:
The
xlink:href
attribute is by default replaced with ahref
attribute, as this is anyways what you get in the end and is the way it should be done.But if you still rely on the
xlink:href
attribute, this pr adds the option to set$qrCode->setWriterOptions(['force_xlink_href' => true])
, which then will enforce this older attribute with the trick from the blog mentioned above.I know this is edge-casey, but it would be very helpful if this could get merged :)