TCPDF 添加 Helvetica 字体有两个原因:
- 初始化时,TCPDF 类将默认字体设置为 Helvetica(在构造函数中),因此将此字体添加到文档的字体列表中。
对于旧版本:
为了防止这种情况,您可以编辑文件config/tcpdf_config.php 并将常量PDF_FONT_NAME_MAIN 更改为您想要的默认字体名称(应该在第155 行左右)。请注意,您不能使用任何核心字体,因为它们永远不会被嵌入。
对于较新的版本:
使用所需的默认字体名称before 定义PDF_FONT_NAME_MAIN,包括TCPDF 文件。示例:
define('PDF_FONT_NAME_MAIN', 'freesans');
include_once 'path/to/tcpdf.php';
- TCPPDF 在页面底部添加了一个隐形链接“Powered by www.tcpdf.org”。
为了防止这种情况,您必须使用这样的覆盖类:
class MyPdf extends TCPDF {
public function __construct($orientation='P', $unit='mm', $format='A4', $unicode=true, $encoding='UTF-8', $diskcache=false, $pdfa=false) {
// call parent constructor
parent::__construct($orientation, $unit, $format, $unicode, $encoding, $diskcache, $pdfa);
// disable the tcpdf link
$this->setTcpdfLink(false);
}
/**
* Allows to disable the invisible "Powered by www.tcpdf.org" link at the bottom of the page.
* @param type $tcpdflink
*/
public function setTcpdfLink($tcpdflink = true) {
$this->tcpdflink = $tcpdflink ? true : false;
}
}