Keep medical watermark aspect ratio

This commit is contained in:
sas.fajri
2026-05-21 12:11:16 +07:00
parent 3a5dd605c2
commit 939e62d3c8

View File

@@ -14,8 +14,21 @@ class MedicalCheckupReportPdf extends FPDF
return;
}
// Draw watermark background per page.
$this->Image($this->watermarkPath, 23, 102, 164, 102, 'JPEG');
// Keep original image ratio to avoid stretched watermark.
$info = @getimagesize($this->watermarkPath);
if (!$info || intval($info[0]) <= 0 || intval($info[1]) <= 0) {
return;
}
$imgW = intval($info[0]);
$imgH = intval($info[1]);
$drawW = 136.0;
$drawH = ($imgH / $imgW) * $drawW;
// Position tuned to match lab report reference.
$x = ($this->GetPageWidth() - $drawW) / 2;
$y = 98.0;
$this->Image($this->watermarkPath, $x, $y, $drawW, $drawH, 'JPEG');
}
public function Footer()