9
私はZend_Pdfは複数行で、問題を抱えている、私の問題は、私が私pdf.Myテキストにテキスト全体を書くことができないということである。このようになります:http://pastebin.com/f6413f664Zend FrameworkのPDF複数行の問題
しかし、ときに私が開きます私の.pdfファイルは、テキストは次のようになります。http://screencast.com/t/1CBjvRodeZQd
そしてここでは私のコードです:すべての<p>
はブレーク(<br />
\ n)を持っており、にするために、私が何をしたいのか
public function pdfAction()
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$theID = ($this->_getParam('id') !== NULL) ? (int)$this->_getParam('id') : false;
($theID === false) ? $this->_redirect('/home') : false;
//Information
$info = $this->artists->artistInfo($theID);
// Create new PDF
$pdf = new Zend_Pdf();
$pdf->properties['Title'] = "TITLE";
$pdf->properties['Author'] = "AUTHOR";
// Add new page to the document
$page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
$pdf->pages[] = $page;
// Set font
$page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 8);
// Draw text
foreach (explode("</p>", $info[0]['biography']) as $i => $line) {
$page->drawText($line, 0, 820 - $i * 10, 'UTF-8');
}
$this->getResponse()->setHeader('Content-type', 'application/x-pdf', true);
$this->getResponse()->setHeader('Content-disposition', 'attachment; filename=my-file.pdf', true);
$this->getResponse()->setBody($pdf->render());
}
、ありますテキスト全体を表示します。
解決方法これに代えて
ええ、それはうまくいきますが、もう1つの質問があります。どうすればトップのテキスト、タイトルを置くことができますか? – Uffo
コード内の820を〜800に変更し、別のdrawText呼び出しを追加してタイトルを印刷します –
Thx a lot man! – Uffo