Skip to content

Commit b4f26ab

Browse files
authored
Merge pull request #20 from eberkund/add-html-cover-support
HTML cover support
2 parents 17346ae + bf419fd commit b4f26ab

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/Commands/BuildCommand.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class BuildCommand extends Command
2424
* @var string|string[]|null
2525
*/
2626
public $themeName;
27+
2728
/**
2829
* @var OutputInterface
2930
*/
@@ -204,9 +205,7 @@ protected function buildPdf(string $html, array $config, string $currentPath, st
204205

205206
$pdf->SetMargins(400, 100, 12);
206207

207-
if (! $this->disk->isFile($currentPath.'/assets/cover.jpg')) {
208-
$this->output->writeln('<fg=red>==></> No assets/cover.jpg File Found. Skipping ...');
209-
} else {
208+
if ($this->disk->isFile($currentPath . '/assets/cover.jpg')) {
210209
$this->output->writeln('<fg=yellow>==></> Adding Book Cover ...');
211210

212211
$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
221220
);
222221

223222
$pdf->AddPage();
223+
} elseif ($this->disk->isFile($currentPath . '/assets/cover.html')) {
224+
$this->output->writeln('<fg=yellow>==></> Adding Book Cover ...');
225+
226+
$cover = $this->disk->get($currentPath . '/assets/cover.html');
227+
228+
$pdf->WriteHTML($cover);
229+
230+
$pdf->AddPage();
231+
} else {
232+
$this->output->writeln('<fg=red>==></> No assets/cover.jpg File Found. Skipping ...');
224233
}
225234

226235
$pdf->SetHTMLFooter('<div id="footer" style="text-align: center">{PAGENO}</div>');

stubs/assets/cover.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h1 style="text-align: center;">Title</h1>

0 commit comments

Comments
 (0)