French characters writing pdf itext

Hello,
  I am converting a html to pdf using itext. THe html file is in French language. SOme characters are getting diaplyed as ? in pdf. Please let me know how to solve this.

Than you
SthokalaAsked:
Who is Participating?
 
ValeriConnect With a Mentor Commented:
you can try with this font... should be something like that:
BaseFont times = BaseFont.createFont(path + "fonts/times.ttf", "CP1252", BaseFont.NOT_EMBEDDED);
0
 
CEHJCommented:
You need to write them with the correct character encoding. Possibly in your case ISO8859-1
0
 
CEHJCommented:
Writer out = new OutputStreamWriter(outputStream, "ISO8859-1"));

Open in new window

0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
SthokalaAuthor Commented:
Thank you for your reply. My code is like below

            ByteArrayOutputStream pdfOut = new ByteArrayOutputStream();
                  PdfWriter writer = PdfWriter.getInstance(document, pdfOut);
Please let me know where can I specify encoding

Thank you
0
 
CEHJCommented:
Well i don't know, as i don't know what that PDF class is ...

At a guess, i would think it would accept a UTF-8 encoding
0
 
SthokalaAuthor Commented:
it is com.lowagie.text.pdf.PdfWriter;
0
 
CEHJCommented:
Since the pdf writer doesn't care about the encoding, it suggests that it chooses its own, which is probably UTF-8. If you're seeing, in the resulting document, bad characters, that suggests that they were already bad before it wrote them
0
 
SthokalaAuthor Commented:
I am converting html to pdf. the html file encoding is ISO8859-1, so the data is showing correctly in the html file. When I convert it to pdf, it is not displaying properly
0
 
ValeriCommented:
this is not because of encoding. you have to choose the right font. the one which is able to "draw" french symbols.
for example check this: http://tutorials.jenkov.com/java-itext/font.html
0
 
CEHJConnect With a Mentor Commented:
Yes, definitely font support must be there but i would guess that few fonts are without support for French accents
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.