diff --git a/src/PaymentPart/Output/TcPdfOutput/TcPdfOutput.php b/src/PaymentPart/Output/TcPdfOutput/TcPdfOutput.php index 62bc7d17..4fada4a7 100644 --- a/src/PaymentPart/Output/TcPdfOutput/TcPdfOutput.php +++ b/src/PaymentPart/Output/TcPdfOutput/TcPdfOutput.php @@ -2,6 +2,7 @@ namespace Sprain\SwissQrBill\PaymentPart\Output\TcPdfOutput; +use Endroid\QrCode\Writer\SvgWriter; use setasign\Fpdi\Tcpdf\Fpdi; use Sprain\SwissQrBill\PaymentPart\Output\AbstractOutput; use Sprain\SwissQrBill\PaymentPart\Output\Element\FurtherInformation; @@ -98,6 +99,11 @@ private function addSwissQrCodeImage(): void { $qrCode = $this->getQrCode(); + // The compact version uses the element, which increases the size of the output file. + $qrCode->addOptions([ + SvgWriter::WRITER_OPTION_COMPACT => false + ]); + $method = match ($this->getQrCodeImageFormat()) { QrCode::FILE_FORMAT_SVG => 'ImageSVG', default => 'Image', diff --git a/src/QrCode/QrCode.php b/src/QrCode/QrCode.php index 516d8000..ea804e2a 100644 --- a/src/QrCode/QrCode.php +++ b/src/QrCode/QrCode.php @@ -30,6 +30,8 @@ final class QrCode private BaseQrCode $qrCode; private Logo $qrCodeLogo; private WriterInterface $qrCodeWriter; + /** @var array $options */ + private array $options = [SvgWriter::WRITER_OPTION_FORCE_XLINK_HREF => true]; public static function create(string $data, string $fileFormat = null): self { @@ -70,6 +72,15 @@ private function __construct(string $data, string $fileFormat) $this->setWriterByExtension($fileFormat); } + /** + * @param array $options + * @return void + */ + public function addOptions(array $options): void + { + $this->options = array_merge($this->options, $options); + } + public function writeFile(string $path): void { $extension = strtolower(pathinfo($path, PATHINFO_EXTENSION)); @@ -124,7 +135,7 @@ private function getQrCodeResult(): ResultInterface $this->qrCode, $this->qrCodeLogo, null, - [SvgWriter::WRITER_OPTION_FORCE_XLINK_HREF => true] + $this->options ); } }