Announcement Announcement Module
No announcement yet.
iText - AbstractPdfView - encoding issue - em Dash Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • iText - AbstractPdfView - encoding issue - em Dash

    Hello all,
    Short Background:
    I am working on a project that allows customers to store loads of information about themselves into an online repository. The repository saves it in an oracle DB. We use UTF-8 on all our JSP's.

    Many of the users are copying text from MS-Word and the text is full of em Dash'es and en Dashes. (You know, the annoying wide dashes.) Anyway, on the JSP's they display perfectly. When I output them in an iText PDV view, they are ignored.

    In an effort to rapidly diagnose the issue, I have created a small class that simply outputs a PDF document on my Hard Drive. I tell it to add a paragraph to the document that contains em dashes and it works perfectly. Code:
    public class FontEncoding {
        public static void main(String[] args) throws DocumentException, IOException {
            BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED);
            Document doc = new Document();
            PdfWriter.getInstance(doc, new FileOutputStream("c:\\Encoding.pdf"));
            Font font = new Font(bf, 13, Font.NORMAL);
            doc.add(new Paragraph("This is a dash - \n" +
                    "This is an en dash \n" +
                    "This is an em dash  \n", font));
    What I am having trouble with is: Why does my tester class display the em Dashes just fine, while my web view class does not. They use the exact same font to create the paragraph, and they run on the same machine. I have already set the character encoding on the Controller to UTF-8 in case the writer is part of the problem.
    If you can think of anything to try, I would appreciate it. Thanks.