如何清理magento标题

时间:2013-12-10 14:55:30

标签: php magento pdf

我正试图以我所做的模块在magento视图中显示PDF,

我使用html2fpdf.php,在普通的php页面中一切顺利,但在一个magento phtml页面 我收到了:%PDF-1.3 3 0 obj <> endobj以及更多内容。

我认为这可能是magento标题的问题:

<?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();

我试图在我的模块中更改我的布局,但标题来自另一个地方,我不知道如何删除它,或者可能在magento中不可能。

1 个答案:

答案 0 :(得分:1)

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

$this->getResponse()
     ->clearHeaders()
     ->setHeader('Content-Type', 'application/pdf')
     ->setBody(set pdf output here);
相关问题