Skip to content

Commit 2436c23

Browse files
Added link option to PdfWriter. (#402)
* Added link option to PdfWriter. * Corrected return result of PdfWriter.
1 parent 652157a commit 2436c23

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Writer/PdfWriter.php

+6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ final class PdfWriter implements WriterInterface
1717
public const WRITER_OPTION_PDF = 'fpdf';
1818
public const WRITER_OPTION_X = 'x';
1919
public const WRITER_OPTION_Y = 'y';
20+
public const WRITER_OPTION_LINK = 'link';
2021

2122
public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, array $options = []): ResultInterface
2223
{
@@ -99,6 +100,11 @@ public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null,
99100
$fpdf->Cell($matrix->getOuterSize(), 0, $label->getText(), 0, 0, 'C');
100101
}
101102

103+
if (isset($options[self::WRITER_OPTION_LINK])) {
104+
$link = $options[self::WRITER_OPTION_LINK];
105+
$fpdf->Link($x, $y, $x + $matrix->getOuterSize(), $y + $matrix->getOuterSize(), $link);
106+
}
107+
102108
return new PdfResult($matrix, $fpdf);
103109
}
104110

0 commit comments

Comments
 (0)