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.
APD TorontoSoftware DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

F PCommented:
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.
APD TorontoSoftware DeveloperAuthor Commented:
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.
F PCommented:
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?
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

APD TorontoSoftware DeveloperAuthor Commented:
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.
F PCommented:
Try this CSS and hopefully it will use the ;after selector for the PDF, if not I know of another PDF / PHP library that will.

td {
  text-align: justify;
}

td:after {
  content: "";
  display: inline-block;
  width: 100%;
}

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
APD TorontoSoftware DeveloperAuthor Commented:
can you attach a css with tcpdf, or I need it inline?
APD TorontoSoftware DeveloperAuthor Commented:
and can you explain how that reduce the font size?
F PCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.