Christian
Christian

Reputation: 691

dompdf spits out pdf.html in Safari

I am using dompdf. Everything works great except that safari spits out the file as sample.pdf.html. I worked trough various threads on stackoverflow. It seems to be content type issue. I have set the content-type to:

text/html; charset=utf-8, application/pdf. Nothing worked out and I am on the end with ideas.

Here is the example file:

<?php
require_once("assets/dompdf/dompdf_config.inc.php");
$html = ' 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1   /DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>  
<meta http-equiv="Content-Type" content="application/pdf; charset=utf-8">
<style>

</style>
</head> 
</html>';
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("sample.pdf");
?>   

Anyone having a clue what the reason could be?

Cheers

Upvotes: 0

Views: 1375

Answers (2)

Fabien M&#233;nager
Fabien M&#233;nager

Reputation: 140195

The meta tag should be

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

And you don't need to set any additionnal header in PHP, dompdf adds them itself.

Upvotes: 0

Piskvor left the building
Piskvor left the building

Reputation: 92752

Shouldn't you send the content-type of your page as application/pdf? You're setting that in the page you're passing to the renderer, but not in the page you're passing to the client.

header('Content-Type: application/pdf`);

Upvotes: 1

Related Questions