SimpleSoftwareIO / simple-qrcode

An easy-to-use PHP QrCode generator with first-party support for Laravel.
https://www.simplesoftware.io/simple-qrcode
MIT License
2.74k stars 391 forks source link

XML tag outputed? #11

Closed huglester closed 9 years ago

huglester commented 9 years ago

Hello,

when I echo the SVG qrcode, I also see this: <?xml version="1.0" encoding="UTF-8"?>

right before the qrcode is printed.

What could that be?

Thanks!

SimplyCorey commented 9 years ago

Can you show me a screen shot and your code? The SVG uses XML to output and should not be showing up.

SimplyCorey commented 9 years ago

Closing this due to not hearing anything back.

ghost commented 8 years ago

@SimplyCorey That happening also to me.

I'm using mpdf to generate PDF document with the qrcode. Unfortunatelly as @huglester said the <?xml tag is shown in the PDF document :/

image

I'm using Laravel 5.1 with the composer.json entries:

"simplesoftwareio/simple-qrcode": "^1.3",
"mpdf/mpdf": "^6.1",

The example code is:

<p class="text-center">
    {!! QrCode::size(200)->generate(Request::url()) !!}
</p>

When I return the laravel view directly to a browser then the xml tag isnt display. It display just on generated pdf document.

SimplyThomas commented 8 years ago

@BlueManLine just checking -- are you also using SVG? Have you tried this with another format like PNG?

This might be an issue with how mpdf renders SVGs and would be outside the scope of our support.

ghost commented 8 years ago

@SimplyThomas thank you for quick reply :+1: Unfortunately on other places I do not use SVG, I just want to use it with the QrCode. Finally I used the PNG format fetched by a local url, not the inline PNG image you are suggesting..

If I will have time (does any developer have time? :D) I will check the issue with other PDF generator library.

SimplyCorey commented 8 years ago

@BlueManLine Does using the PNG URL resolve your issue?

Out of curiosity, what are you building? It looks interesting.

ghost commented 8 years ago

@SimplyCorey yes, the png url resolve my issue. I can attach an extra _GET parameters to easily manipulate the size and margins, so generally I have the same possibilities as with inline qrcode (or even higher - when someday I'm going to change the qrcode library then the changes will affect just one place :))

About my project - I'm building a receipt (or actually docket) which is printing on a remote thermal printer :)

kopgzdevth commented 3 years ago

can you replace it and this code work!! $qrcode=QrCode::encoding('UTF-8')->size(50)->generate('A basic example of QR code!'); $qrcode=str_replace('<?xml version="1.0" encoding="UTF-8"?>',"",$qrcode); //replace to empty

heshanmax commented 2 years ago

I have the same issue i'm using "niklasravnsborg/laravel-pdf"

it prints the qrcode but XML tag printed as @BlueManLine.

Any help

rajeevunni commented 2 years ago

I too encountered similar issue while generating pdf with mpdf library. i just checked @kopgzdevth answer and replaced the entire xml tag from my code.

$qrcode=QrCode::encoding('UTF-8')->size(50)->generate('A basic example of QR code!'); $qrcode=str_replace('<?xml version="1.0" encoding="UTF-8"?>',"",$qrcode); image Edit: inline xml code is somehow replaced by editor. so I am attaching an image

Nahiyan47 commented 2 years ago

I solved this problem. Qr code returns an object. At first you have to convert this to string. then slice until that portion where that xml code ends.

       $qrcode=QrCode::size(50)->generate('A basic example of QR code!');
       $code = (string)$qrcode;
       echo substr($code,38);

this perfectly shows my qrcode without xml code