在magento1.7,只寫在應用程序\代碼\核心以下行\法師\收藏\助手\ Data.php(Data.php)文件Zend_pdf文件拋出的magento誤差由於HTML內容存在
public function getpdf()
{
$pdf = new Zend_Pdf();
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
for($i=0; $i<5; $i++) {
$page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
$page->setFont($font, 24) ->drawText('Hello World page '.$i, 72, 720);
$pdf->pages[] = $page;
}
$pdfString = $pdf->render();
header("Content-Disposition: attachment; filename=myfile.pdf");
header("Content-type: application/x-pdf");
echo $pdfString;
}
調用此函數
<?php Mage::helper('wishlist')->getpdf();?>
在app \設計\前臺\基地\ DEFAULT \模板\心願\ view.phtml(view.phtml)之前<div class="my-wishlist">
行文件。現在在瀏覽器中運行magento並登錄。然後點擊我的願望清單鏈接,它會在downlods文件夾中顯示myfile.pdf。當它打開時,它拋出錯誤message.Now在magento1.7文件夾替換這些行
$pdfString = $pdf->render();
header("Content-Disposition: attachment; filename=myfile.pdf");
header("Content-type: application/x-pdf");
echo $pdfString;
與
$pdf->save("mydoc.pdf");
然後打開mydoc.pdf,它打開,沒有錯誤,並顯示「Hello World」在Pdf文檔的每個頁面上。現在在文本編輯器中比較這兩個文件「myfile.pdf」和「mydoc.pdf」,您會在「myfile.pdf」中看到html內容的存在。 我的問題是,我無法找到一種方法來從生成的PDF文檔中刪除這些html內容。任何人都可以幫助我解決這個問題。 請注意,上面的代碼僅僅是我所做的一個演示。
http://stackoverflow.com/questions/6153480/execute-wkhtmltopdf-from -php – Theodores
我想解決上述問題而不是替代解決方案。請幫助 – Nida