Skip to content

Commit

Permalink
made QR code scale factor configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketMan committed Sep 10, 2023
1 parent 77701f7 commit b794822
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/PDF_Label.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,11 @@ function verticalText($text, $x, $y, $direction = 'D') {
*
* @param $text content
* @param $align one of 'L' (left, default), 'C' (centre), or 'R' (right)
* @param $scale scale factor (default 1.0)
* @param $y offset from top (positive) or bottom (negative) (default 0)
* @param $eclevel one of 'L' (low, default), 'M', 'Q', or 'H' (best)
*/
function writeQRCode($text, $align = 'L', $y = 0, $eclevel = 'L') {
function writeQRCode($text, $align = 'L', $scale = 1, $y = 0, $eclevel = 'L') {
$qrcode = new QRcode($text, $eclevel);
$arrcode = $qrcode->getBarcodeArray();
$rows = $arrcode['num_rows'] ?? 0;
Expand All @@ -308,8 +309,8 @@ function writeQRCode($text, $align = 'L', $y = 0, $eclevel = 'L') {
return;
}

$mw = $mh = 1; // scale factor
$hpad = $vpad = 0; // padding
$mw = $mh = $scale; // scale factor
$hpad = $vpad = 0; // padding

$w = ($cols + $hpad) * ($mw / $this->k);
$h = ($rows + $vpad) * ($mh / $this->k);
Expand Down

0 comments on commit b794822

Please sign in to comment.