Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Modules/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use setasign\SetaFpdf\Position\Converter;
use setasign\SetaFpdf\SetaFpdf;
use setasign\SetaFpdf\StateBuffer\StateBufferInterface;
use setasign\SetaPDF2\Core\Font\TrueType\Subset;

class Document implements StateBufferInterface
{
Expand Down Expand Up @@ -489,6 +490,12 @@ public function output($destination, $name, ?array $displayMode = null)
\call_user_func($this->footerCallable);
$this->pageBreakDisabled = false;

foreach ($this->manager->getFont()->getUsedFonts() as $font) {
if ($font instanceof Subset) {
$font->createSubset();
}
}

self::applyDisplayMode($this->document, $displayMode);
$info = $this->document->getInfo();
$info->setProducer('SetaFPDF ' . SetaFpdf::VERSION);
Expand Down
6 changes: 0 additions & 6 deletions src/SetaFpdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,12 +460,6 @@ public function Output($dest = '', $name = '')
$name = 'doc.pdf';
}

foreach ($this->manager->getFont()->getUsedFonts() as $font) {
if ($font instanceof Subset) {
$font->createSubset();
}
}

return $this->manager->getDocument()->output($dest, $name, $this->displayMode);
}

Expand Down
25 changes: 25 additions & 0 deletions tests/visual/SetaFpdf/Special/FooterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace setasign\tests\visual\SetaFpdf\Special;

use setasign\SetaFpdf\SetaFpdf;
use setasign\tests\TestProxy;
use setasign\tests\visual\SetaFpdf\Special\Footer\FPDFCustom;
use setasign\tests\visual\SetaFpdf\Special\Footer\SetaFpdfCustom;
Expand Down Expand Up @@ -38,4 +39,28 @@ public function testSpecialFooter()

$this->assertProxySame($proxy, 0.4, self::DPI);
}

public function testFooterWithCustomFont()
{
$setaFpdf = new class extends SetaFpdf {
public function Footer()
{
$this->SetY(-15);
$this->Cell(0, 10, 'This is a footer');
}
};

$setaFpdf->AddPage();
$setaFpdf->AddFont('DejaVuSans','', __DIR__ . '/../../../../assets/fonts/DejaVu/DejaVuSans.ttf');
$setaFpdf->SetFont('DejaVuSans', '', 12);
$setaFpdf->Cell(0, 10, 'Hello World');

$testFile = __DIR__ . '/FooterWithCustomFontActualResult.pdf';
$setaFpdf->Output('F', $testFile);
$this->assertPdfsEqual([
__DIR__ . '/FooterWithCustomFontExpectedResult.pdf',
$testFile
], self::DPI, 1, false);
\unlink($testFile);
}
}
Binary file not shown.