Skip to content

Commit 74bc126

Browse files
committed
:octocat: QRFpdf::dump(): allow using external FPDF instance
1 parent 805bf06 commit 74bc126

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Output/QRFpdf.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,17 @@ protected function getDefaultModuleValue(bool $isDark):array{
109109
* Initializes an FPDF instance
110110
*/
111111
protected function initFPDF():FPDF{
112-
return new FPDF('P', $this->options->fpdfMeasureUnit, $this->getOutputDimensions());
112+
$fpdf = new FPDF('P', $this->options->fpdfMeasureUnit, $this->getOutputDimensions());
113+
$fpdf->AddPage();
114+
115+
return $fpdf;
113116
}
114117

115118
/**
116119
* @inheritDoc
117120
*/
118-
public function dump(string $file = null):string|FPDF{
119-
$this->fpdf = $this->initFPDF();
120-
$this->fpdf->AddPage();
121+
public function dump(string $file = null, FPDF $fpdf = null):string|FPDF{
122+
$this->fpdf = ($fpdf ?? $this->initFPDF());
121123

122124
if($this::moduleValueIsValid($this->options->bgColor)){
123125
$bgColor = $this->prepareModuleValue($this->options->bgColor);

0 commit comments

Comments
 (0)