Skip to content

Commit 0715b63

Browse files
authored
Pdf Writer strtoupper() fix (#1629)
* _setPageSize's strtoupper() on array argument PhpSpreadsheet/Writer/Pdf.php Class defines a protected static mixed array called $paperSizes, this array contains string values along with array values. 'strtoupper() expects parameter 1 to be string, array given' error happens due to array passed to $paperSize variable from that $paperSizes mixed array on the Mpdf Class where Pdf extends Examples of cases, when a 'Letter' paper size is chosen, then no problem occurs since the index in that value for the array is a string value, but when 'Tabloid' paper size is chosen the value in the index for that paper size is an array, that's when the strtoupper() error happens * _setPageSize's strtoupper() on array argument PhpSpreadsheet/Writer/Pdf.php Class defines a protected static mixed array called $paperSizes, this array contains string values along with array values. 'strtoupper() expects parameter 1 to be string, array given' error happens due to array passed to $paperSize variable from that $paperSizes mixed array on the Dompdf Class where Pdf extends Examples of cases; when a 'Letter' paper size is chosen, then no problem occurs since the index in the array for that value a string, but when 'Tabloid' paper size is chosen the value in the index for that paper size is an array, that's when the strtoupper() error happens.
1 parent 1d6f36d commit 0715b63

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/PhpSpreadsheet/Writer/Pdf/Dompdf.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function save($pFilename): void
5959

6060
// Create PDF
6161
$pdf = $this->createExternalWriterInstance();
62-
$pdf->setPaper(strtolower($paperSize), $orientation);
62+
$pdf->setPaper($paperSize, $orientation);
6363

6464
$pdf->loadHtml($this->generateHTMLAll());
6565
$pdf->render();

src/PhpSpreadsheet/Writer/Pdf/Mpdf.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function save($pFilename): void
6464
$config = ['tempDir' => $this->tempDir . '/mpdf'];
6565
$pdf = $this->createExternalWriterInstance($config);
6666
$ortmp = $orientation;
67-
$pdf->_setPageSize(strtoupper($paperSize), $ortmp);
67+
$pdf->_setPageSize($paperSize, $ortmp);
6868
$pdf->DefOrientation = $orientation;
6969
$pdf->AddPageByArray([
7070
'orientation' => $orientation,

0 commit comments

Comments
 (0)