Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get list of supported fonts in ITextSharp

I'm working with ITextSharp for a project and am looking for a reasonable way to get a string list of different fonts it has available for use.

I thought maybe I could just use reflection and loop over a class of available fonts, but there does not seem to be an easy way to do this. What I really want to do is provide a drop down of available/supported fonts for my users to select from

Does anyone have any thoughts on how I might accomplish this?

like image 923
aherrick Avatar asked Jan 08 '10 13:01

aherrick


2 Answers

This webpage has a great reference for how to work with the 14 embedded fonts in iTextSharp, as well as how to embed and use any fonts of your choosing.

To get the list of fonts included in iTextSharp:

  Dim myCol As ICollection
  //Returns the list of all font families included in iTextSharp.
  myCol = iTextSharp.text.FontFactory.RegisteredFamilies
  //Returns the list of all fonts included in iTextSharp.
  myCol = iTextSharp.text.FontFactory.RegisteredFonts

An example of a font family is Helvetica. An example of a font is Helvetica-Bold or Helvetica-Italic.

like image 160
Stewbob Avatar answered Sep 20 '22 15:09

Stewbob


First call FontFactory.RegisterDirectories(); to get all fonts on the system registered.

Then call FontFactory.RegisteredFonts; to get all the fonts.

like image 41
David Thielen Avatar answered Sep 22 '22 15:09

David Thielen