カスタムコントローラーに関数 getPdf を作成しました
public function getPdf()
{
$pdf = new Zend_Pdf();
$page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
$imagePath="C:\Users\Hp\Desktop\landscape3.jpg";
$image = Zend_Pdf_Image::imageWithPath($imagePath);
$page->drawImage($image, 40,764,240, 820);
$pdf->pages[] = $page;
$pdf->save('myfile.pdf');
}
画像付きのPDFを生成しますが、magento1.7フォルダーにあります。次の行を試しました
$pdfString = $pdf->render();
header("Content-Disposition: attachment; filename=mydownloads.pdf");
header("Content-type: application/x-pdf");
echo $pdfString;
Downloads フォルダーに PDF ドキュメントを生成しますが、それを開くと、次のエラー メッセージが表示されます。 .....テキストエディタ(メモ帳)でmydownloads.pdfを開くと、htmlコンテンツ(getPdf()関数が呼び出された現在のphtmlファイルのコンテンツ)とpdf自身のコンテンツの存在に気づきました。を使用してmagento1.7でレンダリングを表示する
$vr = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
$vr->setNoRender(true);
$layout = Zend_Layout::getMvcInstance();
$layout->disableLayout();
しかし、残念ながらmagento1.7では機能しませんでした。次に、次のようなヘッダー関数の2行を削除して、$ pdfStringの内容をエコーしようとしました
$pdfString = $pdf->render();
return $pdfString;
単に Pdf 独自のコンテンツが含まれていました。次に、html コンテンツの存在はこの 2 行によるものであることに気付きました
header("Content-Disposition: attachment; filename=mydownloads.pdf");
header("Content-type: application/x-pdf");
誰でもこの問題を解決するのを手伝ってくれますか? そのため、ダウンロードフォルダーにPDFドキュメントが生成されます。PDFドキュメントからhtmlコンテンツを削除するには?