php – 使用TCPDF定位h1,h2,h3和其他标签

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了php – 使用TCPDF定位h1,h2,h3和其他标签脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

我正在尝试使用HTML代码使用TCPDF制作PDF文档.

目前我使用此代码

// set font
$pdf->SetFont('dejavusans', '', 36);

// add a page
$pdf->AddPage();

$htML = '
<style>
.h1 {
color: #2B6999;
font-weight: normal;
}

</style>

<h1 class="h1">test</h1>

';

// output the HTML content
$pdf->wrITeHTML($html, true, false, true, false, 'C');

我该如何定位此文本?我不能在标签margin-top等之间使用..

任何人都可以帮我解决这个问题吗?

解决方法:

你可以添加这样的东西:

$tagvs = array('h1' => array(0 => array('h' => 1, 'n' => 3), 1 => array('h' => 1, 'n' => 2)),
               'h2' => array(0 => array('h' => 1, 'n' => 2), 1 => array('h' => 1, 'n' => 1)));
$pdf->setHtmlVSpace($tagvs);

以下是docs / examples中的格式说明:

文件:tcppdf.PHP

/**
 * Set the vertical spaces for HTML tags.
 * The array must have the following structure (example):
 * $tagvs = array('h1' => array(0 => array('h' => '', 'n' => 2), 1 => array('h' => 1.3, 'n' => 1)));
 * The First array level contains the tag names,
 * the second level contains 0 for opening tags or 1 for closing tags,
 * the third level contains the vertical space unit (h) and the number spaces to add (n).
 * If the h parameter is not sPEcified, default values are used.
 * @param $tagvs (array) array of tags and relative vertical spaces.
 * @public
 * @since 4.2.001 (2008-10-30)
 */

档案http://www.tcpdf.org/examples/example_061.phps

// REMOVE TAG TOP AND BOTTOM MARginS
//
// $tagvs = array('p' => array(0 => array('h' => 0, 'n' => 0), 1 => array('h' => 0, 'n' => 0)));
// $pdf->setHtmlVSpace($tagvs);
// 
// Since the CSS margin command is not yet implemented on TCPDF, you
// need to set the spacing of block tags using the above method.

脚本宝典总结

以上是脚本宝典为你收集整理的php – 使用TCPDF定位h1,h2,h3和其他标签全部内容,希望文章能够帮你解决php – 使用TCPDF定位h1,h2,h3和其他标签所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:h2