Skip to content

Commit

Permalink
fix: covnersion from point to milimeters
Browse files Browse the repository at this point in the history
Signed-off-by: Vitor Mattos <[email protected]>
  • Loading branch information
vitormattos authored and backportbot-libresign[bot] committed Dec 13, 2024
1 parent b881d4c commit f814d5d
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions lib/Handler/FooterHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class FooterHandler {
private File $file;
private FileEntity $fileEntity;
private const MIN_QRCODE_SIZE = 100;
private const PIXEL_TO_CENTIMETER = 0.264583333;
private const POINT_TO_MILIMETER = 0.3527777778;
private array $templateVars = [];

public function __construct(
Expand All @@ -67,35 +67,34 @@ public function getFooter(File $file, FileEntity $fileEntity): string {
return '';
}

$htmlFooter = $this->getRenderedHtmlFooter();
$metadata = $this->getMetadata();
foreach ($metadata['d'] as $dimension) {
$orientation = $dimension['w'] > $dimension['h'] ? 'L' : 'P';
if (!isset($pdf)) {
$pdf = new Mpdf([
'tempDir' => $this->tempManager->getTempBaseDir(),
'orientation' => $orientation,
'orientation' => 'P',
'margin_left' => 0,
'margin_right' => 0,
'margin_top' => 0,
'margin_bottom' => 0,
'margin_header' => 0,
'margin_footer' => 0,
'format' => [
$dimension['w'] * self::PIXEL_TO_CENTIMETER,
$dimension['h'] * self::PIXEL_TO_CENTIMETER,
$dimension['w'] * self::POINT_TO_MILIMETER,
$dimension['h'] * self::POINT_TO_MILIMETER,
],
]);
} else {
$pdf->AddPage(
orientation: $orientation,
newformat: [
$dimension['w'] * self::PIXEL_TO_CENTIMETER,
$dimension['h'] * self::PIXEL_TO_CENTIMETER,
],
);
}

$pdf->SetHTMLFooter($this->getRenderedHtmlFooter());
$pdf->AddPage(
orientation: 'P',
newformat: [
$dimension['w'] * self::POINT_TO_MILIMETER,
$dimension['h'] * self::POINT_TO_MILIMETER,
],
);

$pdf->SetHTMLFooter($htmlFooter);
}

return $pdf->Output('', 'S');
Expand Down

0 comments on commit f814d5d

Please sign in to comment.