Hi, My manager has asked me to use iText to write a method to get a font from a file so that this font will then be used in Java classes that write to PDF files. When I invoke this method by passing a True Type font filename as an argument to it, it works fine and creates a font of the same type and style as described in the file. However, when I try to pass a file describing a font other than a True Type font (such as a file with .FON or .PFM extension) to it, it is throwing the following exception: Exception in thread "main" com.lowagie.text.DocumentException: Font 'C:\pdffonts \intr____.pfm' with 'Cp1252' is not recognized. at com.lowagie.text.pdf.BaseFont.createFont(Unknown Source) at com.lowagie.text.pdf.BaseFont.createFont(Unknown Source) at pdf.PdfFuncs1.GetFont(PdfFuncs1.java:17) at pdf.PdfFuncs1.GetFont(PdfFuncs1.java:31) at pdf.PdfTest.main(PdfTest.java:47)
The following is the code for the method being invoked: public class PdfFuncs1 { private PdfFuncs1() { } public static com.lowagie.text.Font GetFont(String fontFileName, String fontFolder, String fontSize, Color fColor) throws Throwable { BaseFont bf = BaseFont.createFont(fontFolder + fontFileName, BaseFont.WINANSI, BaseFont.EMBEDDED); System.out.println("Font created!"); com.lowagie.text.Font font = new com.lowagie.text.Font(bf, Float.parseFloat(fontSize)); font.setColor(fColor); return font; } public static com.lowagie.text.Font GetFont(String fontFileName, String fontFolder, String fontSize) throws Throwable { return GetFont(fontFileName, fontFolder, fontSize, new Color(0, 0, 0)); } } ----------------------------------------- The way I am invoking this method for a True Type font file is: PdfPCell cell = new PdfPCell(new Phrase("Statements of Assets and Liabilities\n", PdfFuncs1.GetFont("gara.ttf", "C:\\pdffonts\\", "20"))); The way I am invoking this method for a Type 1 Font file is: PdfPCell cell = new PdfPCell(new Phrase("Statements of Assets and Liabilities\n", PdfFuncs1.GetFont("intr____.pfm", "C:\\pdffonts\\", "20"))); As I said, this method is working fine if the name of a True Type font file is passed as the first argument to it but throwing an exception if the name of a non-True Type font file is passed as the first argument to it. Can you please tell me whether the createFont method of BaseFont class works only with True Type fonts and if it does, what are the alternative approaches to make my code work with all types of fonts (including fonts that are not True Type fonts)? Thanks, Kalpana __________________________________________________ Do you Yahoo!? HotJobs - Search new jobs daily now http://hotjobs.yahoo.com/ ------------------------------------------------------- This sf.net email is sponsored by: See the NEW Palm Tungsten T handheld. Power & Color in a compact size! http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en _______________________________________________ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions