• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 981
  • Last Modified:

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
0
Sthokala
Asked:
Sthokala
  • 5
  • 3
  • 2
2 Solutions
 
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
 
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
CEHJCommented:
Yes, definitely font support must be there but i would guess that few fonts are without support for French accents
0
 
ValeriCommented:
you can try with this font... should be something like that:
BaseFont times = BaseFont.createFont(path + "fonts/times.ttf", "CP1252", BaseFont.NOT_EMBEDDED);
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now