From 2fd357c34661b04fb243490db24ac1af8c68829d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=B6hring?= Date: Thu, 13 Jun 2024 17:14:17 +0200 Subject: [PATCH] Add rotation attribute to Label class to allow rotation of the generated label PDF. This is necessary when printing labels with width = label width. --- app/Models/Labels/Label.php | 11 +++++++++++ app/View/Label.php | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/Models/Labels/Label.php b/app/Models/Labels/Label.php index 8ea92d2e42..bf03236d00 100644 --- a/app/Models/Labels/Label.php +++ b/app/Models/Labels/Label.php @@ -25,6 +25,17 @@ abstract class Label */ public abstract function getUnit(); + /** + * Returns the PDF rotation. + * 0, 90, 180, 270 + * 0 is a sane default. Override when necessary. + * + * @return int + */ + public function getRotation() { + return 0; + } + /** * Returns the label's width in getUnit() units * diff --git a/app/View/Label.php b/app/View/Label.php index 3ec3a4099c..ee734fd98f 100644 --- a/app/View/Label.php +++ b/app/View/Label.php @@ -54,7 +54,7 @@ class Label implements View $pdf = new TCPDF( $template->getOrientation(), $template->getUnit(), - [ $template->getWidth(), $template->getHeight() ] + [0 => $template->getWidth(), 1 => $template->getHeight(), 'Rotate' => $template->getRotation()] ); // Reset parameters