TCPDF icon indicating copy to clipboard operation
TCPDF copied to clipboard

Rotate text in table - HTML

Open michalfordonski opened this issue 4 years ago • 3 comments

Hi, How can I rotate the text 90 degrees in HTML so that TCPDF will do it correctly? Using styles: transform: rotate(-90.0deg); unfortunately it doesn't work, a

'<tcpdf method="StartTransform"/><tcpdf method="Rotate" params="'.$pdf->serializeTCPDFtagParameters(array(90)).'"/>Text To Rotate<tcpdf method="StopTransform"/>'

sets the text outside the table cell.

My HTML code: <table style="text-align:left; border-width:0.4px;" cellspacing="0" cellpadding="1"> <tr> <td valign="center" style="width: 5%"><tcpdf method="StartTransform"/><tcpdf method="Rotate" params="'.$pdf->serializeTCPDFtagParameters(array(90)).'"/>Text To Rotate<tcpdf method="StopTransform"/></td> <td valign="top" style="width: 90%"> MyContent </td> <td valign="center" style="width: 5%"></td> </tr> </table>

michalfordonski avatar Jun 09 '21 11:06 michalfordonski

Hi! Did anyone found a solution for this? Thanks!

tipleavalentin avatar Jan 17 '22 21:01 tipleavalentin

I haven't found a solution. I changed to mPDF

michalfordonski avatar Jan 18 '22 06:01 michalfordonski

<tcpdf method="StartTransform"/>
<tcpdf method="Rotate" params="90"/>
Text To Rotate
<tcpdf method="StopTransform"/>

Didn't work for me either. I "fixed" this problem by manually executing those Methods on TCPDF like so:

$pdf->writeHTML('<p>I am straight</p>');
$pdf->StartTransform();
$pdf->Rotate(90);
$pdf->writeHTML('<p>I am rotated</p>');
$pdf->StopTransform();
$pdf->Output('a.pdf', 'I');

I have absolutely no clue why this doesn't work. I debugged a little and the StartTransform, Rotate and StopTransform do all actually get called through the HTML way, the same as doing it manually. But somehow it doesn't rotate 🤔

Binozo avatar Mar 13 '25 18:03 Binozo