From bf419fdfa925362a04a884d3bb866f8e6c23b9ff Mon Sep 17 00:00:00 2001 From: Erik Berkun-Drevnig Date: Fri, 20 Nov 2020 02:56:34 -0500 Subject: [PATCH] HTML cover support --- src/Commands/BuildCommand.php | 15 ++++++++++++--- stubs/assets/cover.html | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 stubs/assets/cover.html diff --git a/src/Commands/BuildCommand.php b/src/Commands/BuildCommand.php index 04bfca9..d3ec226 100644 --- a/src/Commands/BuildCommand.php +++ b/src/Commands/BuildCommand.php @@ -24,6 +24,7 @@ class BuildCommand extends Command * @var string|string[]|null */ public $themeName; + /** * @var OutputInterface */ @@ -204,9 +205,7 @@ protected function buildPdf(string $html, array $config, string $currentPath, st $pdf->SetMargins(400, 100, 12); - if (! $this->disk->isFile($currentPath.'/assets/cover.jpg')) { - $this->output->writeln('==> No assets/cover.jpg File Found. Skipping ...'); - } else { + if ($this->disk->isFile($currentPath . '/assets/cover.jpg')) { $this->output->writeln('==> Adding Book Cover ...'); $coverPosition = $config['cover']['position'] ?? 'position: absolute; left:0; right: 0; top: -.2; bottom: 0;'; @@ -221,6 +220,16 @@ protected function buildPdf(string $html, array $config, string $currentPath, st ); $pdf->AddPage(); + } elseif ($this->disk->isFile($currentPath . '/assets/cover.html')) { + $this->output->writeln('==> Adding Book Cover ...'); + + $cover = $this->disk->get($currentPath . '/assets/cover.html'); + + $pdf->WriteHTML($cover); + + $pdf->AddPage(); + } else { + $this->output->writeln('==> No assets/cover.jpg File Found. Skipping ...'); } $pdf->SetHTMLFooter(''); diff --git a/stubs/assets/cover.html b/stubs/assets/cover.html new file mode 100644 index 0000000..ffe76b3 --- /dev/null +++ b/stubs/assets/cover.html @@ -0,0 +1 @@ +

Title