Skip to content

Commit

Permalink
HTML cover support
Browse files Browse the repository at this point in the history
  • Loading branch information
eberkund committed Nov 20, 2020
1 parent 17346ae commit bf419fd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/Commands/BuildCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class BuildCommand extends Command
* @var string|string[]|null
*/
public $themeName;

/**
* @var OutputInterface
*/
Expand Down Expand Up @@ -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('<fg=red>==></> No assets/cover.jpg File Found. Skipping ...');
} else {
if ($this->disk->isFile($currentPath . '/assets/cover.jpg')) {
$this->output->writeln('<fg=yellow>==></> Adding Book Cover ...');

$coverPosition = $config['cover']['position'] ?? 'position: absolute; left:0; right: 0; top: -.2; bottom: 0;';
Expand All @@ -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('<fg=yellow>==></> Adding Book Cover ...');

$cover = $this->disk->get($currentPath . '/assets/cover.html');

$pdf->WriteHTML($cover);

$pdf->AddPage();
} else {
$this->output->writeln('<fg=red>==></> No assets/cover.jpg File Found. Skipping ...');
}

$pdf->SetHTMLFooter('<div id="footer" style="text-align: center">{PAGENO}</div>');
Expand Down
1 change: 1 addition & 0 deletions stubs/assets/cover.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1 style="text-align: center;">Title</h1>

0 comments on commit bf419fd

Please sign in to comment.