Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze authored and github-actions[bot] committed Dec 27, 2023
1 parent 325184c commit 1251eac
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
12 changes: 9 additions & 3 deletions src/Pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,21 @@
class Pdf implements Responsable
{
public string $viewName = '';

public array $data = [];

public string $html = '';

public string $headerViewName = '';

public array $headerData = [];

public ?string $headerHtml = null;

public string $footerViewName = '';

public array $footerData = [];

public ?string $footerHtml = null;

public string $downloadName = '';
Expand Down Expand Up @@ -90,7 +96,7 @@ public function inline(string $downloadName = ''): self
$this->name($downloadName);

$this->addHeaders([
'Content-Type' => 'application/pdf',
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="'.$this->downloadName.'"',
]);

Expand Down Expand Up @@ -118,12 +124,12 @@ public function footerHtml(string $html): self
return $this;
}

public function download(string $downloadName = null): self
public function download(?string $downloadName = null): self
{
$this->name($downloadName);

$this->addHeaders([
'Content-Type' => 'application/pdf',
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="'.$this->downloadName.'"',
]);

Expand Down
3 changes: 2 additions & 1 deletion tests/PdfReponseTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use Illuminate\Support\Facades\Route;

use function Spatie\LaravelPdf\Support\pdf;

it('can inline the pdf', function () {
Expand All @@ -25,7 +26,7 @@
->assertHeader('content-disposition', 'attachment; filename="my-custom-name.pdf"');
});

it('will inline the pdf by default', function() {
it('will inline the pdf by default', function () {
Route::get('pdf', function () {
return pdf('test')->name('my-custom-name.pdf');
});
Expand Down
4 changes: 2 additions & 2 deletions tests/PdfTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
]);
});

it('can render header html', function() {
it('can render header html', function () {
Pdf::html('Body html')
->headerView('header', ['title' => 'Header title'])
->save($this->targetPath);
Expand All @@ -62,7 +62,7 @@
]);
});

it('can render footer html', function() {
it('can render footer html', function () {
Pdf::html('Body html')
->footerView('footer', ['title' => 'Footer title'])
->save($this->targetPath);
Expand Down
2 changes: 1 addition & 1 deletion tests/Pest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function assertMatchesPdfSnapshot(string $pdfPath): void
$expectedText = [$expectedText];
}

foreach($expectedText as $singleText) {
foreach ($expectedText as $singleText) {
expect(str_contains($actualText, $singleText))->toBeTrue(
"Expected text `{$singleText}` not found in `{$actualText}`"

Expand Down

0 comments on commit 1251eac

Please sign in to comment.