Sunday, January 17, 2010

Embed fonts for pdf usng itext

Usually, "consola" font family is not used for pdfs, because it is not available in all systems. Using following code sample, you can embed your interested fonts for pdfs.

Registering regular True type "consola" font.
FontFactory.register("D:\\consola.ttf", "Manning");
FontFactory.getFont("Manning", BaseFont.CP1252, BaseFont.EMBEDDED);
Registering bold True type "consola" font.
FontFactory.register("D:\\consolab.ttf","Manning");
FontFactory.getFont("Manning", BaseFont.CP1252, BaseFont.EMBEDDED);