Zend_Pdf 将 Verdana 字体添加到 PDF
Zend_Pdf adding Verdana font to PDF
我正在为 pdf 生成创建 magento 扩展。我需要在使用 Zend_Pdf 生成的 pdf 文件中使用 Verdana Bold、Verdana Reg... 字体。任何人都可以解释如何使用正确的路径访问 TTF 类型的字体。
//load font from file system
$font = Zend_Pdf_Font::fontWithPath("/path/to/myfont.ttf");
//add $font to page
$page->setFont($font, $fontSize);
希望对您有所帮助
首先,您应该将所需的字体文件上传到一个目录中,上传字体的最佳位置是在 lib
文件夹中,因此在本演示中,我将在 lib
文件夹中创建名为 customfonts
并在那里上传我的字体文件
现在在所需的 php 文件上调用它(例如:在 Shipment.php 内)并像下面那样使用它
$chevinFontBold = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . '/lib/customfonts/chevin-bold.ttf');
$page->setFont($chevinFontBold, 8);
这里8是字体大小
我正在为 pdf 生成创建 magento 扩展。我需要在使用 Zend_Pdf 生成的 pdf 文件中使用 Verdana Bold、Verdana Reg... 字体。任何人都可以解释如何使用正确的路径访问 TTF 类型的字体。
//load font from file system
$font = Zend_Pdf_Font::fontWithPath("/path/to/myfont.ttf");
//add $font to page
$page->setFont($font, $fontSize);
希望对您有所帮助
首先,您应该将所需的字体文件上传到一个目录中,上传字体的最佳位置是在 lib
文件夹中,因此在本演示中,我将在 lib
文件夹中创建名为 customfonts
并在那里上传我的字体文件
现在在所需的 php 文件上调用它(例如:在 Shipment.php 内)并像下面那样使用它
$chevinFontBold = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . '/lib/customfonts/chevin-bold.ttf');
$page->setFont($chevinFontBold, 8);
这里8是字体大小