【发布时间】:2010-11-22 18:04:10
【问题描述】:
我有一个问题,使用 Zend_PDF 多行,我的问题是我无法将整个文本写入我的 pdf。我的文本如下所示:http://pastebin.com/f6413f664
但是当我打开我的 .pdf 文件时,文本看起来像这样:http://screencast.com/t/1CBjvRodeZQd
这是我的代码:
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());
}
我想做的是让每个<p> 休息一下(<br />\n) 并显示整个文本。
有什么解决办法吗?
【问题讨论】:
标签: php zend-framework pdf