Skip to content

Commit b9688a0

Browse files
committed
:octocat: QRFpdf::dump(): allow using external FPDF instance
1 parent ab1f371 commit b9688a0

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
@@ -110,17 +110,19 @@ protected function getDefaultModuleValue(bool $isDark):array{
110110
* Initializes an FPDF instance
111111
*/
112112
protected function initFPDF():FPDF{
113-
return new FPDF('P', $this->options->fpdfMeasureUnit, $this->getOutputDimensions());
113+
$fpdf = new FPDF('P', $this->options->fpdfMeasureUnit, $this->getOutputDimensions());
114+
$fpdf->AddPage();
115+
116+
return $fpdf;
114117
}
115118

116119
/**
117120
* @inheritDoc
118121
*
119122
* @return string|\FPDF
120123
*/
121-
public function dump(string $file = null){
122-
$this->fpdf = $this->initFPDF();
123-
$this->fpdf->AddPage();
124+
public function dump(string $file = null, FPDF $fpdf = null){
125+
$this->fpdf = ($fpdf ?? $this->initFPDF());
124126

125127
if($this::moduleValueIsValid($this->options->bgColor)){
126128
$bgColor = $this->prepareModuleValue($this->options->bgColor);

0 commit comments

Comments
 (0)