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");

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.
AIGSNetwork AdministratorAsked:
Who is Participating?
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.
Martin MillerCTOCommented:
Try this as a test,

Change something like this:

to this:

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");
AIGSNetwork AdministratorAuthor Commented:
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.
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

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?
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?
Martin MillerCTOCommented:
It looks like you have this solved.  Promoting question for closure.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.