:octocat: QRFpdf::dump(): allow using external FPDF instance

This commit is contained in:
smiley
2024-04-19 13:45:41 +02:00
parent ab1f3716d9
commit b9688a0862
+6 -4
View File
@@ -110,7 +110,10 @@ class QRFpdf extends QROutputAbstract{
* Initializes an FPDF instance
*/
protected function initFPDF():FPDF{
return new FPDF('P', $this->options->fpdfMeasureUnit, $this->getOutputDimensions());
$fpdf = new FPDF('P', $this->options->fpdfMeasureUnit, $this->getOutputDimensions());
$fpdf->AddPage();
return $fpdf;
}
/**
@@ -118,9 +121,8 @@ class QRFpdf extends QROutputAbstract{
*
* @return string|\FPDF
*/
public function dump(string $file = null){
$this->fpdf = $this->initFPDF();
$this->fpdf->AddPage();
public function dump(string $file = null, FPDF $fpdf = null){
$this->fpdf = ($fpdf ?? $this->initFPDF());
if($this::moduleValueIsValid($this->options->bgColor)){
$bgColor = $this->prepareModuleValue($this->options->bgColor);