Hi,
sorry for posting an issue that seems to have been
discussed quite a lot, but cannot tell which from the
replies in the archives do work or not. You could also
see the examples if you change to Greek(ISO) or
Greek(Windows) encodings in your email client or
browser.
Questions:
1. Why CP1253 is not defined in
com.lowagie.text.pdf.BaseFont class in the standard
releases of iText so someone needs to add the
following line:
/** A possible encoding. */
public static final String CP1253 = "Cp1253";
to this file and ant-build iText in order to be able
to use Greek fonts? :-)
2. What is the correct way to print Greek characters?
DefaultFontMapper mapper = new DefaultFontMapper();
FontFactory.registerDirectories();
mapper.insertDirectory("c:\\windows\\fonts");
document.add(new Paragraph("ÃåéÜ óïõ êüóìå!"));
or
BaseFont bfArial =
BaseFont.createFont("c:\\winnt\\fonts\\arial.ttf",
BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
Font font = new Font(bfArial, 18);
document.add(new Paragraph("ÃåéÜ óïõ êüóìå!"));
Which is the correct for itext version 1.3 and on?
But, with either of these methods, Greek letters with
accents never appear, e.g. Ü, ü etc. are not rendered
in the pdf.
3. Greek letters are not rendered if printed through
Graphics or Graphics2D:
DefaultFontMapper mapper = new DefaultFontMapper();
FontFactory.registerDirectories();
mapper.insertDirectory("c:\\windows\\fonts");
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);
Please note that I 'm using Arial which does contain
Greek characters.
Thanks in advance for your replies.
Best regards,
John.
__________________________________
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