Solved

French characters writing pdf itext

Posted on 2014-04-17
10
762 Views
Last Modified: 2014-04-29
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
Comment
Question by:Sthokala
  • 5
  • 3
  • 2
10 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 40006659
You need to write them with the correct character encoding. Possibly in your case ISO8859-1
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 40006663
Writer out = new OutputStreamWriter(outputStream, "ISO8859-1"));

Open in new window

0
 

Author Comment

by:Sthokala
ID: 40006678
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 86

Expert Comment

by:CEHJ
ID: 40006707
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
 

Author Comment

by:Sthokala
ID: 40006716
it is com.lowagie.text.pdf.PdfWriter;
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 40006740
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
 

Author Comment

by:Sthokala
ID: 40006746
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
 
LVL 16

Expert Comment

by:Valeri
ID: 40006747
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
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 250 total points
ID: 40006763
Yes, definitely font support must be there but i would guess that few fonts are without support for French accents
0
 
LVL 16

Accepted Solution

by:
Valeri earned 250 total points
ID: 40006856
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
session migration servlets 2 36
servlet  URL Rewriting 1 36
jdbc error in jsp application 20 45
Glassfish admin console not working 1 12
Have you ever come up with a need of emailing only few pages of PDF file to one of yourfriend or colleague, instead of whole Adobe file? If yes, then surely you have face problems in doing that! Read this section as I have suggested multiple solutio…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question