Skip to content

Commit

Permalink
feat: footer/header css setters and optional save path
Browse files Browse the repository at this point in the history
  • Loading branch information
joaovdiasb committed Nov 7, 2022
1 parent 6d6e0e6 commit c714fed
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
4 changes: 2 additions & 2 deletions resources/views/defaultLayout.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
}
#header {
position: fixed;
{{ config('pdf-manager.header.css') }}
{{ $headerCss }}
}
#footer {
position: fixed;
{{ config('pdf-manager.footer.css') }}
{{ $footerCss }}
}
.page_break {
page-break-before: always;
Expand Down
32 changes: 30 additions & 2 deletions src/PdfManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ class PdfManager
$pageCounterText = null,
$header = null,
$footer = null,
$body = null;
$body = null,
$headerCss = null,
$footerCss = null;
private ?float $marginTop = null,
$marginBottom = null,
$marginLeft = null,
Expand Down Expand Up @@ -132,6 +134,30 @@ public function setPageCounterText(?string $pageCounterText = null): self
return $this;
}

public function setHeaderCss(string $headerCss): self
{
$this->headerCss = $headerCss;

return $this;
}

public function setFooterCss(string $footerCss): self
{
$this->footerCss = $footerCss;

return $this;
}

public function getHeaderCss(): string
{
return $this->headerCss ?? config('pdf-manager.header.css');
}

public function getFooterCss(): string
{
return $this->footerCss ?? config('pdf-manager.footer.css');
}

public function getPageCounterX(): float
{
return (float) ($this->pageCounterX ?? config('pdf-manager.page_counter.x', 10));
Expand Down Expand Up @@ -210,7 +236,7 @@ public function make(string $type = null)
}
}

public function save(string $path, ?string $disk = null): string
public function save(?string $path = null, ?string $disk = null): string
{
$view = $this->getViewContent();
$pdf = $this->parseView($view);
Expand All @@ -227,7 +253,9 @@ private function getViewContent(): string
return view($this->layout, [
'structure' => $this->replaces($this->body),
'header' => $this->header,
'headerCss' => $this->getHeaderCss(),
'footer' => $this->footer,
'footerCss' => $this->getFooterCss(),
'marginTop' => $this->getMarginTop(),
'marginBottom' => $this->getMarginBottom(),
'marginRight' => $this->getMarginRight(),
Expand Down

0 comments on commit c714fed

Please sign in to comment.