0

I'm creating a PDF from an html page.

it works perfectly on chrome, edge and opera but on firefox it has a weird behaviour. It seems not to recognize the statement to output to the browser (preview) but it asks to open/save the output...

this is my code:

<?php
    ob_start();

    $id = $_GET['id'];

    require "./mypage.php"; 
    $html = ob_get_clean();

    // include autoloader
    require_once './dompdf/autoload.inc.php';

    //Reference of Dompdf namespace
    use Dompdf\Dompdf;
    use Dompdf\Options;
    
    // instantiate and use the dompdf class
    $options = new Options();
    $options->set('enable_html5_parser', true);
    $options->set('isJavascriptEnabled', true);

    $dompdf = new Dompdf($options);

    //Create PDF
    $dompdf->loadHtml($html);

    // Render the HTML as PDF
    $dompdf->render();

    $output = $dompdf->output();

    // Output the generated PDF to Browser
    $dompdf->stream($output, array("Attachment" => false));
    exit(0);
?>

no problems with chrome opera or edge. (my firefox version is 94.0.1) –

what can it be? thanks

Ale MaDaMa
  • 25
  • 4
  • Does [this](https://stackoverflow.com/a/61864953/128761) answer your question? – vee Nov 23 '21 at 16:10
  • yes vee, I caught just for that post to write my code but unfortunately I think that KJ is right and this is a setting of the browser. Do you think that is there any chance, from dompdf, to force the browser to preview instead of download? – Ale MaDaMa Nov 23 '21 at 16:25
  • I try with mPDF, it's browser problem as K J said. :-) – vee Nov 23 '21 at 18:24

0 Answers0