Zend PDF 保存和渲染文件的不同字体大小
我尝试打开一个现有文件,通过包含文本对其进行修改,然后将其发送给用户(渲染)。我认识到字体大小仅针对文件的保存版本而改变。如果我只渲染它,字体大小将被忽略。
为什么会发生这种情况?我做错了什么?我可以做点什么来反对它吗?
您好,
-洛尼
$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));
I tryed to open an existing file modify it by including text and then send it to the user (render). What I recognised is that the font size only changes for the saved version of the file. If I only render it, the font size is ignored.
Why is this happening? What do I do wrong? Can I do something against it?
Greetings,
-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));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论