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
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 1 addition & 29 deletions src/PhpSpreadsheet/Writer/Pdf/Dompdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,43 +44,15 @@ public function save($filename, int $flags = 0): void
$orientation = ($orientation == 'L') ? 'landscape' : 'portrait';

// Create PDF
$restoreHandler = false;
if (PHP_VERSION_ID >= self::$temporaryVersionCheck) {
// @codeCoverageIgnoreStart
set_error_handler(self::specialErrorHandler(...));
$restoreHandler = true;
// @codeCoverageIgnoreEnd
}
$pdf = $this->createExternalWriterInstance();
$pdf->setPaper($paperSize, $orientation);

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

// Write to file
fwrite($fileHandle, $pdf->output() ?? '');
fwrite($fileHandle, $pdf->output());

if ($restoreHandler) {
restore_error_handler(); // @codeCoverageIgnore
}
parent::restoreStateAfterSave();
}

protected static int $temporaryVersionCheck = 80500;

/**
* Temporary handler for Php8.5 waiting for Dompdf release.
*
* @codeCoverageIgnore
*/
public function specialErrorHandler(int $errno, string $errstr, string $filename, int $lineno): bool
{
if ($errno === E_DEPRECATED) {
if (preg_match('/canonical|imagedestroy|http_get_last_response_headers|Using null as an array offset/', $errstr) === 1) {
return true;
}
}

return false; // continue error handling
}
}