sprain/php-swiss-qr-bill

ℹ️ File size increases with endroid/qr-code 5.0.8

sdespont opened this issue · 6 comments

After updating endroid/qr-code from version 5.0.4 to the latest version (5.0.8), the size of a PDF generated by TCPDFOutput increases by around 15% for a single page, and by around 50% for a 120-page document!

Work has been done on block spacing in this commit:
endroid/qr-code@0cc00f0

Have you noticed the same behaviour with HTML or other rendering?

@sdespont are you talking about file size or pixel size of the qr code?

@sprain sorry, I am talking about the file size

Thanks!
Then it‘s a bit annoying, but not really urgent for most users (I know it is likely for you).

@sprain I'm going to contact endroid/qr-code but I thought it was important to inform users of the library too.

Can you let this issue open until a fix is released ?

@sprain endroid/qr-code releases 5.0.9 version to keep compatibility with previous SVG image creation method using <defs> element instead of <path>. There is a new option to chose between theses formats : SvgWriter::WRITER_OPTION_COMPACT

Would you OK for a PR adding a public function setOptions(array $options) to the QrCode class ?

private array options = [SvgWriter::WRITER_OPTION_FORCE_XLINK_HREF => true];

public function setOptions(array $options): void
{
    $this->options = $options;
}

And the write method whould use the options like like

    private function getQrCodeResult(): ResultInterface
    {
        return $this->qrCodeWriter->write(
            $this->qrCode,
            $this->qrCodeLogo,
            null,
            $this->options
        );
    }

In my view, the options should be fixed within the output class itself; there's no necessity to pass the options in the constructor of TcPdfOutput, for instance.

@sdespont The general idea looks good, go for it!