如何在php中使用tcpdf在标题中插入小大写
我正在使用TCPDF创建PDF文档。我想在标题中使用,但失败了 这是我的头代码: 版本1如何在php中使用tcpdf在标题中插入小大写,php,pdf,tcpdf,smallcaps,Php,Pdf,Tcpdf,Smallcaps,我正在使用TCPDF创建PDF文档。我想在标题中使用,但失败了 这是我的头代码: 版本1 要更改字体,您需要添加字体样式。 哈哈。。。。!!! 我解决了我的问题 <?php require_once('tcpdf/tcpdf.php'); class MYPDF extends TCPDF { //Page header public function Header() { // Logo $image_file ='image/
要更改字体,您需要添加字体样式。
哈哈。。。。!!!
我解决了我的问题
<?php
require_once('tcpdf/tcpdf.php');
class MYPDF extends TCPDF {
//Page header
public function Header() {
// Logo
$image_file ='image/pacra.jpg';
$this->Image($image_file, 100, 05, 20);
// Set font
$this->SetFont('times','B');
$this->SetFontSize(16);
//$this->SetTextColor(0,63,127);
$this->SetXY(52,25);
$str = 'Tying to Use Small Caps';
$str = preg_replace("/([a-z]+)/e","strtoupper('<small>\\1</small>')",$str);
$str= $this->writeHTML($str);
您传递到此处的任何字符串(小写/大写)都将显示在标题中。若要更改大小写,您可以使用php函数strtolower($str)。@PraveenD请查看我的更新代码并向我提出建议。我非常感谢您。(请单击链接)为此您必须添加字体。@PraveenD是(请单击链接)我要添加字体。我的更新代码正在工作,但这里有一个问题,我无法设置文本的XY轴。亲爱的,我想使用小大写字母。我怎么能用这个?我不能理解这个例子。我是php新手。你说你想要那种字体。是的,是的,亲爱的,我想用大写字母设置字体
<?php
require_once('tcpdf/tcpdf.php');
class MYPDF extends TCPDF {
//Page header
public function Header() {
// Logo
$image_file ='image/pacra.jpg';
$this->Image($image_file, 100, 05, 20);
// Set font
$this->SetFont('times', 15);
$str = 'Trying To Use Small Caps';
$str = preg_replace("/([a-z]+)/e","strtoupper('<small>\\1</small>')",$str);
$str= $this->writeHTML($str);
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
<?php
require_once('tcpdf/tcpdf.php');
class MYPDF extends TCPDF {
//Page header
public function Header() {
// Logo
$image_file ='image/pacra.jpg';
$this->Image($image_file, 100, 05, 20);
// Set font
$this->SetFont('times','B');
$this->SetFontSize(16);
//$this->SetTextColor(0,63,127);
$this->SetXY(52,25);
$str = 'Tying to Use Small Caps';
$str = preg_replace("/([a-z]+)/e","strtoupper('<small>\\1</small>')",$str);
$str= $this->writeHTML($str);