开发者

Zend PDF different font size for saved and rendered file

开发者 https://www.devze.com 2023-01-29 04:24 出处:网络
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 re

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));
0

精彩评论

暂无评论...
验证码 换一张
取 消