Hi,
Thanks for all the replies, after some debugging it seems that the only time
the ttf files don't take effect is when I am setting the font on a
ColumnText element.
I have a servlet which is writing text to a pdf. The following code is in
the doGet method of the Servlet. The text added to the ColumnText object is
populte in the method addColumnString and is assigned a font, which doesn't
take effect. Later after document.newPage(); , I add some more text with the
same font object and it works.
PdfWriter writer = null ;
Document document = new Document();
BaseFont bf = null;
Font ft= null;
bf = BaseFont.createFont("c:/windows/fonts/RAVIE.ttf",
BaseFont.WINANSI, BaseFont.EMBEDDED);
ft = new Font(bf,12);
response.setContentType("application/pdf");
writer = PdfWriter.getInstance(document,
response.getOutputStream());
document.open();
PdfContentByte cb = writer.getDirectContent();
cb.setFontAndSize(bf, 10);
ColumnText ct_abs = new ColumnText(cb);
float pos = writer.getVerticalPosition(false);
addColumnString("Testing with a string",ct_abs);
ct_abs.setSimpleColumn(50,pos,PageSize.A4.getWidth()-50,-10);
ct_abs.go();
float pos1 = ct_abs.getYLine();
document.newPage();
document.add(new Paragraph("Hello World",ft)); //This font
takes
effect
document.add(new Paragraph(new Date().toString()));
public static void addColumnString(String text, ColumnText
ct) throws DocumentException, IOException
{
BaseFont bf;
bf = BaseFont.createFont("c:/windows/fonts/RAVIE.ttf",
BaseFont.WINANSI,
BaseFont.EMBEDDED);
Font ft = new Font(bf,12);
Paragraph p = new Paragraph(text, ft); //This font doesn't take
effect
p.setFont(ft);
Phrase ss = Phrase.getInstance(p.getContent());
ss.setFont(ft); //This font doesn't take effect
ct.addText(ss);
}
Thanks for your feedback. kazam.
--
View this message in context:
http://itext-general.2136553.n4.nabble.com/TTF-file-has-no-effect-tp2964490p2966348.html
Sent from the iText - General mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
Spend less time writing and rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php