Can you BOLD part of text you want to show in a PDF using FPDF and PDF_Label?

I am creating postage labels and recording them into a pdf file using FPDF and PDF_Label - all work fine, see code sample below ...
$text = sprintf("%s\n%s\n%s\n%s %s %s\n%s", "   6         022, "Name","Address", "Location", "State", "PostCode", "Country");
$pdf->Add_Label($text);

As you can see, I am using sprintf to format text for the label and using Add_Label from PDF_Label class to create the label.

I would like to BOLD the "Name" portion within the sprintf, if possible. As far as I can tell this can't be done. Tried using html tags inside it - no good, just prints the tags.

Any help or suggestions appreciated.
LVL 1
AIGSNetwork AdministratorAsked:
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.

Martin MillerCTOCommented:
Try this as a test,

Change something like this:
printf("TextToBold");

to this:
printf("\e1mTextToBold\e[0m");

For your example, show edited how to bold name:
$text = sprintf("%s\n \e1m%s\e[0 \n%s\n%s %s %s\n%s", "   6         022, "Name","Address", "Location", "State", "PostCode", "Country");
0
AIGSNetwork AdministratorAuthor Commented:
Martin
Testing your sample: printf("\e1mTextToBold\e[0m");
All I get with the sample is "1mTextToBold" on the page. The same happens when I apply your suggestion to my actual code.
AIGS
0
AIGSNetwork AdministratorAuthor Commented:
I think the problem is the PDF_Label class, where it uses multicell to insert the text into the pdf, formatted by sprintf.
Is there a way to bold a specific line or text using multicell?
AIGS
0
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

AIGSNetwork AdministratorAuthor Commented:
After looking at code in FPDF class - I see that mulicell() uses cell() to write each line within the multicell().
Perhaps that is where I need to try something?
0
AIGSNetwork AdministratorAuthor Commented:
I have edited the FPDF Class function cell() to identify if the <b></b> tags are supplied as part of the string, and if so reset BOLD for the PDF on ad then off. This works ok for the entire string (whole line) passed to cell() from multicell().

Now the trick is to detect the word (text) within the string to isolate them so that only the words encased within the <b></b> tags are set as bold, not the entire line.
0

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
Martin MillerCTOCommented:
It looks like you have this solved.  Promoting question for closure.
0
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
Web Development

From novice to tech pro — start learning today.