Führe PDF-Vorlagen für Dokumente ein: Titelseite, grafischer Kopf und Fuß, Angaben je Fassung (ADR-51, Nachtrag)
Eine Vorlage ist reines Layout (Titelseite mit allein stehendem Titel, Kopf- und Fußgrafik aus dem Medienbestand, Herausgeber und Standardvermerk) und wird dem Dokument zugeordnet. Untertitel, Ausgabe, Veröffentlichungsdatum und Copyright-Vermerk gehören zur Dokumentfassung (document_meta). Ohne Vorlage bleibt das PDF unverändert. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
81037b9868
commit
765b8e779e
31 files changed
+1272
-33
No files matched your search
@@ -49,7 +49,7 @@ protected function chapter(Composition $document, string $title, string $body):
|
||||
*
|
||||
* @param array<string, string> $chapters
|
||||
*/
|
||||
protected function document(array $chapters, string $title = 'Trainerhandbuch', ?Composition $composition = null): CompositionVersion
|
||||
protected function document(array $chapters, string $title = 'Trainerhandbuch', ?Composition $composition = null, ?array $meta = null): CompositionVersion
|
||||
{
|
||||
$composition ??= $this->documentComposition($title);
|
||||
$members = [];
|
||||
@@ -60,16 +60,16 @@ protected function document(array $chapters, string $title = 'Trainerhandbuch',
|
||||
$members[] = ['role' => $sub ? 'Unterkapitel' : 'Kapitel', 'target' => $this->chapter($composition, $name, $body)];
|
||||
}
|
||||
|
||||
return app(ContentService::class)->publishComposition($composition, $members);
|
||||
return app(ContentService::class)->publishComposition($composition, $members, null, null, $meta === null ? [] : ['document_meta' => $meta]);
|
||||
}
|
||||
|
||||
/** Ein Bild im Medienbestand mit echter Datei im abgeleiteten Bestand. */
|
||||
protected function picture(string $title, int $width = 640, int $height = 360): ContentElementVersion
|
||||
protected function picture(string $title, int $width = 640, int $height = 360, array $rgb = [40, 120, 90]): ContentElementVersion
|
||||
{
|
||||
$content = app(ContentService::class);
|
||||
$file = 'inhalte/'.str($title)->slug().'.png';
|
||||
$image = imagecreatetruecolor($width, $height);
|
||||
imagefill($image, 0, 0, (int) imagecolorallocate($image, 40, 120, 90));
|
||||
imagefill($image, 0, 0, (int) imagecolorallocate($image, ...$rgb));
|
||||
ob_start();
|
||||
imagepng($image);
|
||||
Storage::disk('media_derived')->put($file, (string) ob_get_clean());
|
||||
@@ -124,6 +124,18 @@ protected function pdfText(string $pdf): string
|
||||
return implode("\n", $this->pdfPages($pdf));
|
||||
}
|
||||
|
||||
/**
|
||||
* Anzahl der Bilder je Seite (aus den Betriebsmitteln der Seitenobjekte).
|
||||
*
|
||||
* @return list<int>
|
||||
*/
|
||||
protected function pdfPageImages(string $pdf): array
|
||||
{
|
||||
preg_match_all('/\/Type \/Page \/Parent 2 0 R(.*?)\/Contents \d+ 0 R/s', $pdf, $pages);
|
||||
|
||||
return array_map(fn (string $page): int => preg_match_all('/\/Im\d+ \d+ 0 R/', $page), $pages[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Text je Seite. Die Seiteninhalte stehen in der Reihenfolge der Seiten im Dokument.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user