dsfvcbcv
dsfvcbcv

Reputation: 1

iText font setting for phrase

I am using iText 5.5 to generate pdf files.i am trying to make the header font bold,but its not working. I have used the Phrase to set the header content and set the font for phrase. please help.

Upvotes: 0

Views: 4165

Answers (2)

Jigyasa Gandhi
Jigyasa Gandhi

Reputation: 1

As mentioned in this post you can not edit the font already set, but you can create a new phrase by copying old contents and set the new font in it.

The following worked for me:

Phrase existingPhrase = pdfpCell.getPhrase();
// this step created the required font for me
Font font = getFontFormat(); 
Paragraph newPhrase = new Paragraph(existingPhrase.getContent(), font);
pdfpCell.setPhrase(newPhrase);

Upvotes: 0

conrad carter
conrad carter

Reputation: 266

There is no iText 5.5, so I'm presuming you're using v. 5.0.5. You're off to a good start, iText is the best OSS library out there.

There is an example of how to use the header here: http://itextpdf.com/examples/iia.php?id=103 If you make the header Phrase bold, you'll have your header with bold text. I strongly suggest that you use the example's code so you can see how it works. Make it bold, then copy the code over to your project. Good luck.

Upvotes: 1

Related Questions