前往小程序,Get更优阅读体验!
立即前往
发布
社区首页 >专栏 >网页title图标_php 数据库显示在页面并能修改

网页title图标_php 数据库显示在页面并能修改

作者头像
全栈程序员站长
发布2022-10-03 14:51:45
发布2022-10-03 14:51:45
4.2K0
举报

大家好,又见面了,我是你们的朋友全栈君。

在生成的pdf文件的页眉设置logo有以下解决方案

重新定义TCPDF中的K_PATH_IMAGES常量(define(‘K_PATH_IMAGES’, xxxx) , 需要定义在加载tcpdf.php 之前)

## 示例

$logo = “xxxx”; //相对地址

$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, “标题”, “标语”, array(0,64,255), array(0,64,128));

$pdf->setFooterData(array(0,64,0), array(0,64,128));

若不定义常量,可以将logo图片移动到vendor/tecnickcom/examples/images下

## 示例

$logo = “xxxx”; //相对地址

$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, “标题”, “标语”, array(0,64,255), array(0,64,128));

$pdf->setFooterData(array(0,64,0), array(0,64,128));

重写 public function Header() {} 方法

public function Header() {

$logo = xxxx;//绝对地址

this->Image(

$this->SetFont(‘stsongstdlight’, ”, 10);

this->MultiCell(0, 15,

}

设置头部Logo源码分析

this->Image(K_PATH_IMAGES.

根据源码分析,发现此处 会在配置的 $headerdata[‘logo’] 数据前面,自动加上 常量 K_PATH_IMAGES,所以才有了解决方案1,方案2

## 源码

public function Header() {

if ($this->header_xobjid === false) {

// start a new XObject Template

this->header_xobjid = this->w,

headerfont = this->getHeaderFont();

headerdata = this->getHeaderData();

this->y =

if ($this->rtl) {

this->x =

} else {

this->x =

}

if ((headerdata[‘logo’]) AND (headerdata[‘logo’] != K_BLANK_IMAGE)) {

imgtype = TCPDF_IMAGES::getImageFileType(K_PATH_IMAGES.headerdata[‘logo’]);

if ((imgtype == ‘eps’) OR (imgtype == ‘ai’)) {

this->ImageEps(K_PATH_IMAGES.

} elseif ($imgtype == ‘svg’) {

this->ImageSVG(K_PATH_IMAGES.

} else {

this->Image(K_PATH_IMAGES.

}

imgy = this->getImageRBY();

} else {

imgy = this->y;

}

cell_height = this->getCellHeight(headerfont[2] / this->k);

// set starting margin for text data cell

if ($this->getRTL()) {

header_x = this->original_rMargin + (

} else {

header_x = this->original_lMargin + (

}

cw = this->w – this->original_lMargin –

this->SetTextColorArray(

// header title

this->SetFont(

this->SetX(

this->Cell(cell_height, headerdata[‘title’], 0, 1, ”, 0, ”, 0);

// header string

this->SetFont(headerfont[1], headerfont[2]);

this->SetX(

this->MultiCell(cell_height, headerdata[‘string’], 0, ”, 0, 1, ”, ”, true, 0, false, true, 0, ‘T’, false);

// print an ending header line

this->SetLineStyle(array(‘width’ => 0.85 /

this->SetY((2.835 / imgy, this->y));

if ($this->rtl) {

this->SetX(

} else {

this->SetX(

}

this->Cell((this->original_lMargin –

$this->endTemplate();

}

// print header template

$x = 0;

$dx = 0;

if (!this->header_xobj_autoreset AND

// adjust margins for booklet mode

dx = (this->original_lMargin –

}

if ($this->rtl) {

x = this->w +

} else {

x = 0 + dx;

}

this->printTemplate(

if ($this->header_xobj_autoreset) {

// reset header xobject template at each page

$this->header_xobjid = false;

}

}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/197359.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022年9月4日 下,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档