Announcement Announcement Module
Collapse
No announcement yet.
iText - AbstractPdfView - encoding issue - em Dash Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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.

    Issue:
    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.

    Complication:
    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:
    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"));
            doc.open();
            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));
            doc.close();
    
        }
    }
    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.
    Code:
    response.setCharacterEncoding("UTF-8");
    If you can think of anything to try, I would appreciate it. Thanks.
Working...
X