Solved

French characters writing pdf itext

Posted on 2014-04-17
10
748 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
 
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
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: 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JavaScript/Java - Changing an image background color 4 56
netstat -ano | find "8000" and taskkill /f /pid 2984 3 39
difference of if loops 23 43
MySQL  on Tomcat 8 30
*Adobe Acrobat 9 was used for this article.  Particular steps may vary depending on software versions. Adobe Acrobat has many, many variables that my be utilized to customize your forms for clarity and ease of use. The Form Editing Tool will be y…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
We often encounter PDF files that are pure images, that is, they do not have text characters, but instead contain only raster graphics. The most common causes of this are document scanning software and faxing software/services that create image-only…

863 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

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now