Incidentally, I'm the author of most of the iText documentation (as well as the original developer of iText, including the Document
, PdfWriter
, ZapfdingbatsList
,... classes), and I'd appreciate it if you took some time to read the iText documentation.
Let's start with chapter 2 and take a look at some C# examples that introduce the Font
class.
For instance:
Font font = new Font(Font.FontFamily.ZAPFDINGBATS, 12);
Once you have a Font object, you can create a Phrase
(also explained in chapter 2):
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 need to read chapter 3. Take a look at the examples for inspiration, for instance FoobarFilmfestival.cs:
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
.
In your code sample you were adding a Zapfdingbats glyph to a document using a list. Please take a moment to put yourself in my place. Doesn't that feel as if you're the inventor of the sock attending a Red Hot Chili Peppers' concert?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…