![](/img/trans.png)
[英]Zend_pdf document throws error in magento due to presence of html contents
[英]Error in generated pdf file using zend_pdf under Magento
我正在嘗試創建一個PDF文件,在Magento phtml文件下,這是我的代碼:
$pdf = new Zend_Pdf();
$pdf->pages[] = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
$page=$pdf->pages[0]; // this will get reference to the first page.
$style = new Zend_Pdf_Style();
$style->setLineColor(new Zend_Pdf_Color_Rgb(0,0,0));
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES);
$style->setFont($font,12);
$page->setStyle($style);
$page->drawText('example text here',100,($page->getHeight()-100));
$pdf->render();
$pdf->save('test.pdf','true');
我的PDF文件已創建,但我無法使用acrobat reader打開它。
當我用文本編輯器打開它並將其與另一個簡單的pdf文件進行比較時,我注意到在生成的pdf文件中缺少第一行。 它包含"%PDF-1.4"
如何在我的pdf文件中以編程方式使用zend_pdf添加此行?
感謝幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.