有没有办法将QRCODE打印到没有XML标签的Laravel的PDF?

发布于 2025-02-13 07:01:05 字数 785 浏览 0 评论 0原文

我正在使用 simpleSoftwareio/simple-qrcode 来生成QR-code,如这样。

 <div class="card">
     <div class="card-body">
         {!! QrCode::size(300)->generate('hello')!!}
     </div>
</div>

而且我正在使用 mcCarlosen/laravel-mpdf 用于pdf的通用pdf。

 $pdf = LaravelMpdf::loadView(
         'testing_qr' ,compact('testing'),
            [],
            ['orientation'=>'landscape','format'=>'A5']);
        return $pdf->stream('test.pdf');

但是,我一直使用 xml 标签获得PDF,因此是这样的;

qrcode看起来如何

如果我将此刀片用作正常html页面't,但是如果我在PDF中使用它,则会显示出来。

有人可以告诉我如何删除标签并仅保留条形码。

I am using SimpleSoftwareIO/simple-qrcode to generate Qr-code, like this;

 <div class="card">
     <div class="card-body">
         {!! QrCode::size(300)->generate('hello')!!}
     </div>
</div>

And I am using mccarlosen/laravel-mpdf for generaating pdf, like this;

 $pdf = LaravelMpdf::loadView(
         'testing_qr' ,compact('testing'),
            [],
            ['orientation'=>'landscape','format'=>'A5']);
        return $pdf->stream('test.pdf');

But I keep getting a pdf with XML tag, like this;

how the qrcode looks

If I use this blade file as a normal html page, the xml tag doesn't, but if I used it in a pdf it shows up.

Can someone please show me how to remove the tag and remain with the barcode only.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

安人多梦 2025-02-20 07:01:05

类似的东西

尝试我正在使用的

: Milon/Barcode

McCarlosen/Laravel-MPDF

{!! str_replace('<?xml version="1.0" standalone="no"?>', '', DNS1D::getBarcodeSVG($barcode, 'C39',3,100)); !!} 

这对我有帮助。

Try something like this

I am using:

milon/barcode

mccarlosen/laravel-mpdf

{!! str_replace('<?xml version="1.0" standalone="no"?>', '', DNS1D::getBarcodeSVG($barcode, 'C39',3,100)); !!} 

This helped me.

ヅ她的身影、若隐若现 2025-02-20 07:01:05

一种可能的方法,但不建议使用是更改QR的包源文件以删除该XML标签。

如果您愿意这样做,可以从/vendor/yourqrpackage轻松删除该标签。

如果找不到该文件,则可以轻松地搜索'&lt;?xml版本=“ 1.0” encoding =“ utf-8”?&gt;' 。 “ \ n”。并删除此代码。

例如,在我的情况下是:供应商/werneckbh/qrcode/src/qr_code/encoder/vector.php文件包含此代码。当我删除'&lt;?xml版本=“ 1.0” encoding =“ utf-8”?&gt;' 。 “ \ n”。部分,它正在生成QR,而无需该字符串。

One possible way, but not recommended is to change your qr's package source files to remove that xml tag.

If you prefer to go this way, you can remove that tag easily from /vendor/yourqrpackage.

If you can't find that file, you can easily search for '<?xml version="1.0" encoding="utf-8"?>' . "\n" . and remove this piece of code.

For example in my case it is: vendor/werneckbh/qrcode/src/QR_Code/Encoder/Vector.php file that includes this code. When I removed the '<?xml version="1.0" encoding="utf-8"?>' . "\n" . part, it was generating qr without that string.

烟酒忠诚 2025-02-20 07:01:05

我使用这样的使用,它有效:

   $qrcode=QrCode::size(80)->generate('Example of QR code!');
   $code = (string)$qrcode;
   echo substr($code,38);

I use like this and it works :

   $qrcode=QrCode::size(80)->generate('Example of QR code!');
   $code = (string)$qrcode;
   echo substr($code,38);
我是有多爱你 2025-02-20 07:01:05

使用此软件包生成条形码 https://github.com/milon/barcode

use this package to generate the barcode https://github.com/milon/barcode

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文