Legacy notice!

iText 5 is the previous major version of iText's leading PDF SDK. iText 5 has been EOL, and is no longer developed. Switch your project to iText 7, integrating the latest developments.
Check related iText 7 content!

I want to put a check mark using Zapfdingbats on a specific location in my PDF document.

What I achieved so far is this: I can show the check mark but it's on the side of the document and not on the specific X, Y coordinate that I want it to be.

Posted on StackOverflow on May 4, 2013 by Edper

Let's start with a Font object that knows how to draw a Zapfdingbats character:

Font font = new Font(Font.FontFamily.ZAPFDINGBATS, 12);

Once you have a Font object, you can create a Phrase:

Phrase phrase = new Phrase(zapfstring, font);

Where zapfstring is a string containing any Zapfdingbats character you want.

To add this Phrase at an absolute position, you can use the ShowTextAligned() method and PdfWriter's direct content:

PdfContentByte canvas = writer.DirectContent;
ColumnText.ShowTextAligned(canvas, Element.ALIGN_CENTER, phrase, 200, 500, 0);

Where 200 and 500 are an X and Y coordinate and 0 is an angle expressed in degrees. Instead of ALIGN_CENTER, you can also choose ALIGN_RIGHT or ALIGN_LEFT.

Click this link if you want to see how to answer this question in iText 7.