Thank you so much. I post the full case here so that
others take advantage of it.

DefaultFontMapper mapper = new DefaultFontMapper();
mapper.insertDirectory("c:\\windows\\fonts");
DefaultFontMapper.BaseFontParameters par =
mapper.getBaseFontParameters("Arial");
if (par != null) {
    par.encoding = BaseFont.IDENTITY_H;
}
BaseFont bfArial =
BaseFont.createFont("c:\\windows\\fonts\\arial.ttf",  
                BaseFont.IDENTITY_H,
BaseFont.EMBEDDED);
Font font = new Font(bfArial, 18);
// step 4: we add a paragraph to the document
document.add(new Paragraph("ÃåéÜ óïõ êüóìå!", font));

// we create a template and a Graphics2D object that
corresponds with it
PdfContentByte cb = writer.getDirectContent();
PdfTemplate tp = cb.createTemplate(w, h);
Graphics g = tp.createGraphics(w, h, mapper);
tp.setWidth(w);
tp.setHeight(h);

java.awt.Font thisFont = new java.awt.Font("Arial",
java.awt.Font.PLAIN, 18);
g.setFont(thisFont);
String pear = "Á÷ëÜäé!";
FontMetrics metrics = g.getFontMetrics();
int width = metrics.stringWidth(pear);
g.drawString(pear, (w - width) / 2, 20);
g.dispose();
cb.addTemplate(tp, 0, 0);

--- Paulo Soares <[EMAIL PROTECTED]> wrote:

> DefaultFontMapper mapper = new DefaultFontMapper();
> mapper.insertDirectory("c:\\windows\\fonts");
> DefaultFontMapper.BaseFontParameters par =
> mapper.getBaseFontParameters("Arial");
> if (par != null) {
>     par.encoding = BaseFont.IDENTITY_H;
> }
> 



        
                
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to