3 Replies Latest reply on Nov 14, 2007 7:18 AM by srmo642002

    problem with unicodes in itext

    srmo642002

      hi,,
      i use itext2.0.1 and seam 1.2.1
      when i try to generate a pdf with unicode characters (farsi or arabic) seam dont generate these characters.
      when a document contains both farsi and english characters, seam only generate a pdf with english characters
      what i do ?

        • 1. Re: problem with unicodes in itext
          fzaker

          I have the same problem.
          According to "itext in action", for using arabic language in pdf,

          Arabic glyphs are written as double byte chars.
          Your encoding should be BaseFont.IDENTITY_H, and you should be using a unicode font.


          How should we do these in seam pdf?

          • 2. Re: problem with unicodes in itext
            rmemoria

            Hi,

            I have this same problem, but with Romanian language, that already has chars like ? and ? that are not displayed in the PDF.

            Any solution for that?

            Regards,
            Ricardo

            • 3. Re: problem with unicodes in itext
              srmo642002

              you must manipulate UIFont class locatet in org.jboss.seam.pdf.ui;

              private BaseFont getFont(String familyName) {
               try {
               return BaseFont.createFont("c:/windows/fonts/" + familyName + ".ttf",
               BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
               } catch (Exception e) {
               e.printStackTrace();
               try {
               return BaseFont.createFont("d:/windows/fonts/" + familyName + ".ttf",
               BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
               } catch (Exception e1) {
               e1.printStackTrace();
               }
               }
               return null;
               }
              
               @Override
               public void createITextObject(FacesContext context) {
               familyName = (String) getAttributes().get("familyName");
               if (familyName == null || familyName.equals(""))
               familyName = "nazanin";
               //int family = (familyName==null) ? Font.UNDEFINED : Font.getFamilyIndex(familyName);
               size = (Integer) valueBinding(context, "size", size);
              
               font = new Font(getFont(familyName), size);
               font.getBaseFont().correctArabicAdvance();
              
               style = (String) valueBinding(context, "style", style);
               if (style != null) {
               font.setStyle(style);
               }
               }