cpu4you
cpu4you

Reputation: 43

PHP mPDF QR-Code with special characters like LF and CR

We have to implement a system called "Zahlen mit Code" (German for "pay by code"), a convenient, fast and lossless way of initiating credit transfers by using your smartphone & a QR-Code.

As mpdf (used by the php-based invoice-system "invoiceplane" for exports) can manage the QR-Code generation with flying colors we desperately seek for a solution to our problem: The creation of QR-Codes that contain special characters like Lf and Cr. (We need them to meet the requirements: "Elements are separated with line endings, where both variants Lf and CrLf are permitted.", Reference [it's worth reading]: https://www.stuzza.at/de/download/qr-code/339-qr-code-und-bcd-definition-2-en/file.html, Page 5)

To create a QR-Code within our UTF-8 coded HTML we use code snippets like:

<barcode code="Two\rlines" size="0.8" type="QR" error="M" class="barcode" />

Unfortunately, using "\r" within the QR-Code-text doesn't do the trick (there is no actual carriage return, only the used characters - e.g. "\r" appear within the string). We tried several variants like \n; &#13; [HTML dec], &#xd; [HTML hex]; 0x0D (UTF8 hex) and so on. Our guess is that it gets escaped by some sanitizing code or we simply escape it the wrong way (or just use the wrong special/control character).

Upvotes: 1

Views: 2238

Answers (1)

Finwe
Finwe

Reputation: 6755

This is only possible with mPDF since version 7.0. The \r\n and \n characters in the barcode code parameter are treated as actual newlines.

Upvotes: 2

Related Questions