From f814d5d895547dcfdd335b066554133fb30185fa Mon Sep 17 00:00:00 2001 From: Vitor Mattos Date: Thu, 12 Dec 2024 22:53:59 -0300 Subject: [PATCH] fix: covnersion from point to milimeters Signed-off-by: Vitor Mattos --- lib/Handler/FooterHandler.php | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/lib/Handler/FooterHandler.php b/lib/Handler/FooterHandler.php index 68c1efcc33..9081aba6f0 100644 --- a/lib/Handler/FooterHandler.php +++ b/lib/Handler/FooterHandler.php @@ -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( @@ -67,13 +67,13 @@ 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, @@ -81,21 +81,20 @@ public function getFooter(File $file, FileEntity $fileEntity): string { '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');