ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

dompdf wrong content-type generated

November 10, 2011 12:07am

Subscribe [2]
  • #1 / Nov 10, 2011 12:07am

    Interfacer

    92 posts

    Hi

    I am using dompdf as pdf generator. Everything works great on the live server except that its downloading the pdf with the wrong content type (text/html) as supposed to application/pdf. That causes issues with Safari appending the wrong extension (pdf.html).

    However setup works great locally with the proper content-type being used.

    I set the template to allow php, parse on output. Here is the template code:

    <?php  
    require_once("assets/dompdf/dompdf_config.inc.php");   
    $html = ' 
    
    <html>
    <head>  
     <style>
       
     </style>
    </head> 
     {exp:channel:entries status="completed|pending" channel="certificate" entry_id="{last_segment}"}
        <body>
            some html
     </body>
     {/exp:channel:entries}      
    </html>';
    
    $dompdf = new DOMPDF();
    $dompdf->load_html($html);
    $dompdf->render();
    $dompdf->stream("sampledoc.pdf");
    exit();
    ?>

    If I save the template as file it sets the content type right but breaks in google chrome.

    I am using ExpressionEngine v2.2.2 - Build: date 20110801
    on apache 2 server with dompdf 0.6

    Cheers

     

     

  • #2 / Nov 10, 2011 12:40am

    Interfacer

    92 posts

    Issue is resolved. I saved the php template as file and than reverted back to saving file to db. Now the template is the proper content type.

  • #3 / Nov 10, 2011 5:11am

    John Henry Donovan

    12339 posts

    Glad you are up and running again. Feel free to start a new thread if you have any more questions.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases