Skip to content

Commit

Permalink
Added link option to PdfWriter. (#402)
Browse files Browse the repository at this point in the history
* Added link option to PdfWriter.

* Corrected return result of PdfWriter.
  • Loading branch information
laurentmuller committed Mar 30, 2023
1 parent 652157a commit 2436c23
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Writer/PdfWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ final class PdfWriter implements WriterInterface
public const WRITER_OPTION_PDF = 'fpdf';
public const WRITER_OPTION_X = 'x';
public const WRITER_OPTION_Y = 'y';
public const WRITER_OPTION_LINK = 'link';

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

if (isset($options[self::WRITER_OPTION_LINK])) {
$link = $options[self::WRITER_OPTION_LINK];
$fpdf->Link($x, $y, $x + $matrix->getOuterSize(), $y + $matrix->getOuterSize(), $link);
}

return new PdfResult($matrix, $fpdf);
}

Expand Down

0 comments on commit 2436c23

Please sign in to comment.