Hi,
I have a problem using the method set literal from PdfContentByte. I want to
write into a pdf the text "hola" using a computer modern font (cmr12), so I
have the .afm and .pfb files.
The problem is the character spacing in the output pdf. It seems the
characters are printed all in the same position , overlaped.(If i use
another standard type1 font like times new roman it works ok). It is the
same if I write text using glyph-positioning information :
cb.setLiteral("[(My)-302(Sample)]TJ\n")
I used the following code and used the commented part in order to fix this
problem, but it's obviously not very good idea....
If anyone could tell me how I can fix this I would be very grateful.
Thank you in advance.
Laura
CODE:
PdfContentByte cb = writer.getDirectContent();
BaseFont f = BaseFont.createFont("../resources/cmr12.afm","",
BaseFont.EMBEDDED);
String x = "185.137";
String y = "655.818";
String size = "20.6625";
float equis = Float.valueOf(x).floatValue();
float i = Float.valueOf(y).floatValue();
float sizeFont = Float.valueOf(size).floatValue();
/* I get the char spacing from de contentbyte with basefont
timesnewroman
BaseFont f2 =
BaseFont.createFont(BaseFont.TIMES_BOLD,BaseFont.WINANSI,
BaseFont.EMBEDDED);
PdfContentByte cb2 = writer.getDirectContent();
cb2.setFontAndSize(f2, sizeFont);
cb.setCharacterSpacing(cb2.getCharacterSpacing());
*/
cb.beginText();
cb.moveText(equis, i);
cb.setFontAndSize(f, sizeFont);
cb.setLiteral("(hola)Tj\n");
cb.endText();
document.close();
-------------------------------------------------------------------------
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
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php