Skip to content

Commit c714fed

Browse files
committed
feat: footer/header css setters and optional save path
1 parent 6d6e0e6 commit c714fed

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

resources/views/defaultLayout.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
}
1313
#header {
1414
position: fixed;
15-
{{ config('pdf-manager.header.css') }}
15+
{{ $headerCss }}
1616
}
1717
#footer {
1818
position: fixed;
19-
{{ config('pdf-manager.footer.css') }}
19+
{{ $footerCss }}
2020
}
2121
.page_break {
2222
page-break-before: always;

src/PdfManager.php

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ class PdfManager
1717
$pageCounterText = null,
1818
$header = null,
1919
$footer = null,
20-
$body = null;
20+
$body = null,
21+
$headerCss = null,
22+
$footerCss = null;
2123
private ?float $marginTop = null,
2224
$marginBottom = null,
2325
$marginLeft = null,
@@ -132,6 +134,30 @@ public function setPageCounterText(?string $pageCounterText = null): self
132134
return $this;
133135
}
134136

137+
public function setHeaderCss(string $headerCss): self
138+
{
139+
$this->headerCss = $headerCss;
140+
141+
return $this;
142+
}
143+
144+
public function setFooterCss(string $footerCss): self
145+
{
146+
$this->footerCss = $footerCss;
147+
148+
return $this;
149+
}
150+
151+
public function getHeaderCss(): string
152+
{
153+
return $this->headerCss ?? config('pdf-manager.header.css');
154+
}
155+
156+
public function getFooterCss(): string
157+
{
158+
return $this->footerCss ?? config('pdf-manager.footer.css');
159+
}
160+
135161
public function getPageCounterX(): float
136162
{
137163
return (float) ($this->pageCounterX ?? config('pdf-manager.page_counter.x', 10));
@@ -210,7 +236,7 @@ public function make(string $type = null)
210236
}
211237
}
212238

213-
public function save(string $path, ?string $disk = null): string
239+
public function save(?string $path = null, ?string $disk = null): string
214240
{
215241
$view = $this->getViewContent();
216242
$pdf = $this->parseView($view);
@@ -227,7 +253,9 @@ private function getViewContent(): string
227253
return view($this->layout, [
228254
'structure' => $this->replaces($this->body),
229255
'header' => $this->header,
256+
'headerCss' => $this->getHeaderCss(),
230257
'footer' => $this->footer,
258+
'footerCss' => $this->getFooterCss(),
231259
'marginTop' => $this->getMarginTop(),
232260
'marginBottom' => $this->getMarginBottom(),
233261
'marginRight' => $this->getMarginRight(),

0 commit comments

Comments
 (0)