Skip to content

@page inside media query incorrectly parsed as a normal selector #3601

@andre-koch

Description

@andre-koch

I get this error from dompdf but its only when i attempt to save the file ($savePDF is true). As you can see below I have tried various things but still get the error. I'm certain the error is being logged from DomPDF.

PHP Error: [2] DOMXPath::query(): Invalid expression in /vendor/dompdf/dompdf/src/Css/Stylesheet.php on line 1047

My Code:
if(isset($savePDF) && $savePDF){
// Save the generated PDF to a temporary file
$pdfFilePath = $root . 'tmp/' . $fileName . '.pdf';

// file_put_contents($pdfFilePath, $dompdf->output());

$output = $dompdf->output();
if ($output === false) {
throw new Exception("Dompdf output failed");
}
file_put_contents($pdfFilePath, $output);

// file_put_contents($pdfFilePath, $dompdf->output(), LOCK_EX);

// $dompdf->stream($pdfFilePath, ["Attachment" => false]);

// $handle = fopen($pdfFilePath, 'wb');
// if ($handle) {
// fwrite($handle, $dompdf->output());
// fclose($handle);
// } else {
// die("Error: Unable to write to $pdfFilePath");
// }
}
else{
// Output the PDF as a download
header("Content-Type: application/pdf");
header("Content-Disposition: attachment; filename='document.pdf'");
echo $dompdf->output();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions