如何计算TCPDF中MultiCell/writeHTMLCell的高度? [英] How to calculate the height of a MultiCell/writeHTMLCell in TCPDF?

查看:449
本文介绍了如何计算TCPDF中MultiCell/writeHTMLCell的高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试创建具有多个页面的PDF,并且需要预先计算每个单独元素(MultiCell)的高度,以准备分页.根据文档,那里有一些函数,例如GetCharWidth/GetStringWidth来支持我自己执行此操作,但是除了潜在的性能损失外,我可能也不会正确执行此操作.建议以更优雅的方式实现我的目标?

I try to create a PDF with multiple pages and need to calculate the height of each individual element (MultiCell) in advance to prepare for a page break. According to the documentation there are a couple of functions out there like GetCharWidth/GetStringWidth to support me in doing it on my own, but besides a potential performance lost I probably will not do it the right anyway. Suggestions to achieve my goal in a more elegant way?

参考: TCPDF

推荐答案

我知道了:D !!!!!

I GOT it :D!!!!!

创建另一个pdf2对象

Create another pdf2 object

// pdf2 set x margin to pdf1's xmargin, but y margin to zero
// to make sure that pdf2 has identical settings, you can clone the object (after initializing the main pdf object)
$pdf2 = clone $pdf;
pdf2->addpage
pdf2->writeCell
$height = pdf2->getY()
pdf2->deletePage(pdf2->getPage())
pdf1->checkPageBreak($height);
pdf1->writeCell()

W00tness:D

W00tness :D

这篇关于如何计算TCPDF中MultiCell/writeHTMLCell的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆