TCPDF remove <ul> indenting
Asked Answered
B

3

13

For some reason TCPDF is adding space to the left when I use writeHTML() to print an unordered list. By default, the PDF has a margin of 5 (set with $pdf->SetMargins(5, 0, 10, true);) but list items get indented.

I set $pdf->setCellPaddings(0,0,0,0); already, which prevents with unwanted (minus-)space for <p> tags, but obviously doesn´t affect lists.

The call:

$pdf->writeHTML('<ul><li>...</li></li>...</li></ul>');

The result:

enter image description here

Is there any option I miss?

Blender answered 18/11, 2013 at 12:47 Comment(0)
A
31

There is a method setListIndentWidth. For example:

$pdf->setListIndentWidth(4);

You can experiment with the value. And the documentation entry is here.

Allodial answered 11/1, 2014 at 17:22 Comment(5)
The link is deadStall
I've updated link to the documentation but currently it's not very useful.Allodial
New link as of 2020 tcpdf.org/docs/srcdoc/TCPDF/class-TCPDF/#_setListIndentWidthEpicycle
The link is brokenDissimulation
here is the active link. tcpdf.org/docs/srcdoc/TCPDF/classes-TCPDF/…Ratty
A
0

find $this->lMargin += $this->listindent; in tcpdf.php and replace with $this->lMargin += $this->listindent/2;

Algolagnia answered 5/12, 2013 at 14:14 Comment(0)
Z
-3

change:

$pdf->writeHTML('<ul><li>...</li></li>...</li></ul>');

to:

$pdf->writeHTML('<ul style="margin: 0px; padding: 0px;"><li>...</li></li>...</li></ul>');

<ul> -Tag always adds space to the left (padding) and margin to top.

Zelaya answered 28/11, 2013 at 14:22 Comment(4)
Already tried inline-styles… Doesn´t work. As far as I know, TCPDF doesn´t support margin and padding at all.Blender
I use html2pdf in combination with TCPDF 5.0.002 and it works great.Zelaya
I´m just using TCPDF (6.0.044). Maybe it´s because of the combination you use… or the older version, which seems to be different in some ways.Blender
TCPDF doesn't support margin and padding attributes. The latest 6.2 only support padding in table.Anybody

© 2022 - 2024 — McMap. All rights reserved.