Hello,I have to use Adobe Type 1 font (.pfb). I use Java 6. When I use this font in application, it has no problems using font, but when I try this when making PDF, it uses default font in instead of one I choose. Can you tell me how to use Adobe Type 1 font with iText PDF creator? Ma code that works wrong is bellow.
Thank you, Andrej Virantcom.lowagie.text.Rectangle dd = new com.lowagie.text.Rectangle(200f, 200f);
Document doc = new Document(dd);
try {
PdfWriter wr = PdfWriter.getInstance(doc, new
FileOutputStream("mypdf.pdf"));
doc.setMargins(0,0,0,0);
doc.open();
PdfContentByte cb = wr.getDirectContent();
PdfTemplate tp = cb.createTemplate(200f, 200f);
DefaultFontMapper mapper = new DefaultFontMapper();
mapper.insertDirectory("c:/MyFonts/");
Graphics2D g2 = tp.createGraphics(200f, 200f, mapper);
File file = new File("MyFonts/NimbusSanDEE_black.pfb");
FileInputStream fis = new FileInputStream(file);
java.awt.Font font =
java.awt.Font.createFont(java.awt.Font.TYPE1_FONT, fis);
g2.setFont(font.deriveFont(java.awt.Font.PLAIN, 20f));
g2.drawString("Write this text", 10f, 50f);
g2.dispose();
cb.addTemplate(tp, 0, 0);
} catch (Exception e) {
e.printStackTrace();
}
doc.close();
NimbusSanDEE_black.pfb
Description: Binary data
------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions Do you like iText? Buy the iText book: http://www.1t3xt.com/docs/book.php Or leave a tip: https://tipit.to/itexttipjar
