简体   繁体   English

Zend_Pdf将Verdana字体添加到PDF

[英]Zend_Pdf adding Verdana font to PDF

I'm creating magento extension for pdf generating. 我正在创建magento扩展以生成pdf。 I need to use Verdana Bold,Verdana Reg... fonts to my pdf file which generated using Zend_Pdf. 我需要使用Verdana Bold,Verdana Reg ...使用Zend_Pdf生成的pdf文件字体。 Anyone can explain how to use the proper path for accessing TTF type fonts. 任何人都可以解释如何使用正确的路径来访问TTF类型的字体。

for this first you should upload desired font files into a directory best place to upload a font is inside lib folder so in this demonstration I will use create directory inside lib folder called customfonts and upload my font file there 首先,您应该将所需的字体文件上传到目录的最佳位置,以便在lib文件夹中上传字体,因此在本演示中,我将使用lib文件夹中的create目录(称为customfonts并在那里上传我的字体文件

Now call it on desired php file (ex: inside Shipment.php) and use it like below 现在,在所需的php文件(例如Shipment.php内)中调用它,并按如下所示使用它

$chevinFontBold = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . '/lib/customfonts/chevin-bold.ttf');

$page->setFont($chevinFontBold, 8);

here 8 is the font size 这是8的字体大小

//load font from file system

    $font = Zend_Pdf_Font::fontWithPath("/path/to/myfont.ttf");

    //add $font to page

    $page->setFont($font, $fontSize);

Hope this helps 希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM