Link to home
Start Free TrialLog in
Avatar of APD Toronto
APD TorontoFlag for Canada

asked on

Automatically Reducing Font Size in TCPDF

Hi Experts

Using TCPDF's HTML feature, how can I make a td a specific length, in mm, then if the text for that td to automatically reduce the font size.

I seen this feature in fillable PDFs, but I need to apply it now in TCPDF.
Avatar of F P
F P
Flag of United States of America image

Consider your margins, but use the inline style attribute of width using pixel, or px, as your measure. A pixel width never changes across devices, but the ability to compact them together might. A 5 in phone still measures the width displayed compared to all other sizes in the DPI and resolution of how many pixels on the x and y axis it can fit on its display and make work. If you want the length to appear when there is no content, you might consider putting a   or empty space in the TD. If you don't, it won't necessarily think that the definition you want it to use for height and width are relevant. Sometimes, but depends on your browser.

The best way to think when using TCPDF in terms of usability, is that you want to write it similar HTML to 4 and not 5 with CSS3. Think emails, specificity, and nothing fancy/best practice at all.
Avatar of APD Toronto

ASKER

Thanks Frank,

do you have any insight on the second part of my question

if the text for that td to automatically reduce the font size.

I seen this feature in fillable PDFs, but I need to apply it now in TCPDF.
Automatically reduce the font size? Why would you want to do this? If nothing is displayed, you want consistent td heights correct? I don't know what you want to accomplish by reducing the font size and when would the automatic adjust occurs *i.e, under what circumstances/criteria?
The circumstance where I would want to reduce the font size if the comment is very very very long (related to my other question that you are helping me with).

This is essentially a manifest for drivers, and if the comment is very long I need to reduce the font size in order to keep the row size the same. In other words, the client does not want 1 row to be on a half a page, where the other rows can fit 26 rows per page.
ASKER CERTIFIED SOLUTION
Avatar of F P
F P
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
can you attach a css with tcpdf, or I need it inline?
and can you explain how that reduce the font size?
Inline it, and it justifies the width of the td and sets the textsize to a percentage of its parent td. The inline block doesn't allow it to spill over or misshape the element