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

Add option to force xlink:href when adding logos in svg #255

Merged
merged 3 commits into from Jun 19, 2020
Merged

Add option to force xlink:href when adding logos in svg #255

merged 3 commits into from Jun 19, 2020

Conversation

sprain
Copy link
Contributor

@sprain sprain commented Jun 18, 2020

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 the xlink:href attribute into a href attribute, as this blog post from 10 years ago(!) already stated. So far so good, because in SVG xlink: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 a href 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 :)

@sprain sprain changed the title Force xlink href Add option to force xlink:href when adding logos in svg Jun 18, 2020
@endroid
Copy link
Owner

endroid commented Jun 19, 2020

@sprain thank you for the contribution and the clear explanation!

sprain added a commit to sprain/php-swiss-qr-bill that referenced this pull request Jun 19, 2020
@sprain sprain deleted the force-xlink-href branch June 8, 2021 09:43
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.

None yet

2 participants