为什么在php中使用TCPDF的单元格中有左边和顶部填充? [英] Why is there a left and top padding in a cell using TCPDF in php?

查看:52
本文介绍了为什么在php中使用TCPDF的单元格中有左边和顶部填充?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 TCPDF(
- 下标&上标

I am printing a cell using the TCPDF(http://www.tcdf.org/) class in php. The cell should be placed into the top left corner.

Everything works great, except that a left and top padding is added inside the cell.

Here is my code:

require_once('../config/lang/eng.php');
require_once('../tcpdf.php');

$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

$pdf->SetMargins(0,0,0);
$pdf->SetAutoPageBreak(0,0);
$pdf->SetFont('dejavusans', '', 8.5, '', true);

$pdf->AddPage('L', array(50.8,88.9));
$pdf->SetDisplayMode(100,'default');

$pdf->SetXY(0, 0);
$pdf->Cell(0,2.98740833, "Your Name", '1', 2, 'L', false); //Name

$pdf->Output('example.pdf', 'I');

Here's a screenshot of the PDF that is outputting with TCPDF:

Here's a screenshot of the same cell at 300% magnification:

How can I remove the unwanted padding?

///EDIT///

I managed to remove the left padding by using the setCellPaddings() function:

$pdf->setCellPaddings(0,0,0,0);

I am however still getting padding above and below the text within the cell:

I can increase the size of the cell, but when I try to make the height of the cell smaller to try and close it in on the text, the cell won't get any smaller than the current size. How can I decrease the height of the cell or remove the unwanted top and bottom padding of the cell?

解决方案

If I'm not mistaken, that it is not padding, but space for letters which extend below the baseline (e.g. "g"), accents, subscripts and superscripts.

I tried your code with some accented letters in the text. This is the result:

Relevant:
- Baseline (typography)
- Subscript & Superscript

这篇关于为什么在php中使用TCPDF的单元格中有左边和顶部填充?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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