Erlaube in Kopf und Fuß einer PDF-Vorlage ein Logo links oder rechts
Kopf und Fuß haben je eine Anordnung: Band in voller Seitenbreite (Vorgabe, wie bisher), Logo links oder Logo rechts am Textrand. Die Logohöhe ist einstellbar (16 bis 100 Punkt, Vorgabe 40); das Logo ist höchstens halb so breit wie der Text, der Text beginnt darunter beziehungsweise endet darüber. Die Titelseite bleibt unberührt. Additive Migration mit Vorgaben; der vorherige Programmstand zeigt jede Grafik weiter als Band. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b942b5331a
commit
9f9370dbf8
10 files changed
+301
-20
No files matched your search
@@ -25,6 +25,10 @@ class PdfTemplate extends Model
|
||||
'header_element_id',
|
||||
'footer_element_id',
|
||||
'cover_element_id',
|
||||
'header_align',
|
||||
'footer_align',
|
||||
'header_logo_height',
|
||||
'footer_logo_height',
|
||||
'publisher',
|
||||
'copyright',
|
||||
];
|
||||
@@ -36,6 +40,38 @@ protected function casts(): array
|
||||
|
||||
public const SLOTS = ['header', 'footer', 'cover'];
|
||||
|
||||
/** Anordnung von Kopf- und Fußgrafik: Band in voller Seitenbreite oder Logo links oder rechts. */
|
||||
public const ALIGNMENTS = ['full', 'left', 'right'];
|
||||
|
||||
public const LOGO_MIN = 16;
|
||||
|
||||
public const LOGO_MAX = 100;
|
||||
|
||||
public const LOGO_DEFAULT = 40;
|
||||
|
||||
/**
|
||||
* Anordnung und Logohöhe (Punkt) von Kopf oder Fuß; ungültige Werte fallen auf die Vorgabe zurück.
|
||||
*
|
||||
* @return array{align: string, height: int}
|
||||
*/
|
||||
public function layout(string $slot): array
|
||||
{
|
||||
return self::normalizeLayout((string) $this->getAttribute($slot.'_align'), (int) $this->getAttribute($slot.'_logo_height'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{align: string, height: int}
|
||||
*/
|
||||
public static function normalizeLayout(?string $align, int|string|null $height): array
|
||||
{
|
||||
$height = (int) $height;
|
||||
|
||||
return [
|
||||
'align' => in_array($align, self::ALIGNMENTS, true) ? (string) $align : 'full',
|
||||
'height' => $height < 1 ? self::LOGO_DEFAULT : max(self::LOGO_MIN, min(self::LOGO_MAX, $height)),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Das Bild eines Bildfelds als Ziel des Pickers: `element:<Fassung>`, `medium:<Medium>` oder null.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user