2 Replies Latest reply on Jul 28, 2010 7:32 PM by enda

    PDF Encoding problem

    ekindino

      Hi all,


      I'm trying to generate a pdf report which has some text at the end which should be entered by the user generating the report. I'm using rich:editor to enter the text via SeamText and then displaying it via p:html in a pdf (I know it has it's shortcomings but it works for me). I even got the encoding working (Cp1254 for me) with the weird combination of p:pont, p:paragraph and p:html tags. The problem is when I use formatting tags like the part inside the tags does not display native characters. If i give styles like bold fo p:font the characters are displayed but I need just some words emphasised in a paragraph.


      To illustrate the problem:



      <p:font encoding="Cp1254" family="Helvetica">
         <p:paragraph>
            <p:html>
               <s:formattedTex value="These characters are shown: ıİğĞşŞ" />
            </p:html>
         </p:paragraph>
      </p:font>
      
      <p:font encoding="Cp1254" family="Helvetica">
         <p:paragraph>
            <p:html>
               <s:formattedTex value="These characters are shown: ıİğĞşŞ" />
            </p:html>
         </p:paragraph>
      </p:font>
      
      <p:font encoding="Cp1254" family="Helvetica">
         <p:paragraph>
            <p:html>
               <s:formattedTex value="These characters are shown: ıİğĞşŞ these are not:<strong>ıİğĞşŞ</strong>" />
            </p:html>
         </p:paragraph>
      </p:font>



      Does anyone know why this is happening or how i can solve this?
      Thanks in Advance,
      Ekin

        • 1. Re: PDF Encoding problem
          ekindino

          After hours of research, a simple solution presented itself.


          FontFactory.defaultEncoding = "Cp1254";



          This sets the default encoding for iText as Cp1254 so the secondary font created for the bold part turns out ok. Not a real solution but works well enough for my purposes.


          • 2. Re: PDF Encoding problem
            enda

            Howdy,


            here is the trick for Unicode :)


            Get font and put it in your project :)


            <p:font name="/resources/arialuni.ttf" 
                        encoding="Identity-H" 
                        embedded="true">
                       +ěščřžýáíé+ĚŠČŘŽÝÁÍ
             </p:font>