0

I'm trying to show a PDF in a magento view in a modul that I did,

I use html2fpdf.php, in normal php page everything goes good but in one magento phtml page I receive that: %PDF-1.3 3 0 obj <> endobj and a lot off more.

I think that can be a problem with magento header:

<?php 
header_remove();
header('Content-type: application/pdf'); 
include_once ('htmlpdf/html2fpdf.php');
$pdff = "  
<html>  
<head>  
<title>Titulo del archivo pdf</title>  
</head>  
<body>  
<p>Este es el texto del archivo pdf. Podemos incluir imagenes, enlaces, etc.</p>  
</body>  
</html>  
";  

$pdf = new html2fpdf();
$pdf->AddPage();
$pdf -> WriteHTML($pdff);
$pdf -> Output();

I tried to change my layout in my module but the header come from another place and I don't know how to remove it, or maybe that's not possible in magento.

tshepang
  • 12,111
  • 21
  • 91
  • 136
Miton Leon
  • 274
  • 1
  • 5
  • 15
  • 1
    Probably means your `header()` call failed due to previous output, and the browser is treating your pdf as text/plain or text/html. – Marc B Dec 10 '13 at 14:57

1 Answers1

1

Take a look @ Best way to output ajax data from a Magento Admin Extension

$this->getResponse()
     ->clearHeaders()
     ->setHeader('Content-Type', 'application/pdf')
     ->setBody(set pdf output here);
Community
  • 1
  • 1
MagePal Extensions
  • 17,646
  • 2
  • 47
  • 62