Solved

French characters writing pdf itext

Posted on 2014-04-17
10
792 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
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!

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Better way to make a string with template variables in java 3 31
java example issue 5 42
Java basic valueOf question 1 32
PRN converter to PDF 4 20
Inserting page numbers in Portable Document Files not only enhances manageability but also makes them look professional. With numbered pages, the file appears more organized and it becomes easier to search for a particular page. The size and the vol…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

679 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