我尝试打开现有文件,通过包含文本修改它,然后将其发送给用户(渲染)。我所认识到的是,字体大小仅对保存的文件版本有所改变。如果我只渲染它,则忽略字体大小。
为什么会这样?我做错了什么?我能反对吗?
问候,
-lony
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
// fetch allready styled pdf
$pdf = Zend_Pdf::load('img/voucher/gift_vouchers.pdf');
// set default color and font with size
$style = new Zend_Pdf_Style();
$style->setFillColor(new Zend_Pdf_Color_Html('#c34827'));
$style->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 9);
// fetch first page
$page = $pdf->pages[0];
// set default style to page
$page->setStyle($style);
$page->drawText('To_', 72, 10);
$page->drawText('From_', 72, 200);
$page->drawText('For_Chrismas', 1, 100);
$page->drawText('For_Message Lorem Ipsum isries.', 72, 520);
$page->drawText('1231233123', 72, 520);
$page->drawText('23/12/2010', 72, 520);
// only for DEBUG to show difference
$pdf->save('img/voucher/voucher-'.Zend_date::now()->getTimestamp().'.pdf');
$this->getResponse()->setHeader('Content-type', 'application/pdf', true);
$this->getResponse()->setHeader('Content-disposition', 'inline; filename=' . $this->_pdfName . '.pdf', true);
$this->getResponse()->setBody($pdf->render(false));