Hello,
This should fix that issue:

        foreach (var htmlElement in parsedHtmlElements)
            {
                fixRunDirection(htmlElement);
                pdfCell.AddElement(htmlElement);
            }

...

    private static void fixRunDirection(IElement htmlElement)
        {
            if (!(htmlElement is PdfPTable)) return;

            var table = (PdfPTable)htmlElement;
            table.RunDirection = PdfWriter.RUN_DIRECTION_RTL;

            foreach (var row in table.Rows)
            {
                foreach (var cell in row.GetCells())
                {
                    cell.RunDirection = PdfWriter.RUN_DIRECTION_RTL;
                    foreach (var element in cell.CompositeElements)
                    {
                        fixRunDirection(element);
                    }
                }
            }
        }



________________________________
From: Abdelaziz Fitouri <a...@picosoft.biz>
To: itext-questions@lists.sourceforge.net
Sent: Wednesday, November 2, 2011 3:02 PM
Subject: [iText-questions] HTMLWorker and arabic direction RTL


Hi ,

I have a HTML code snippet which contains <table>
in which the columns
contain Arabic text.
after rendering the html snippet by  "HTMLWorker" class
the resulting
element
is instance of a PdfPTable which is shown in the pdf file but the text
direction is from left to right.

i have tried with Stylesheet class, PdfTable.setRunDirection(),
but the text is always from left to right.

Are they any solution to this problem?

thank you


here is a part of my code: 

         
               Document
document = newDocument();
         
               
  writer = PdfWriter.getInstance(document,os);
         
      
         
              document.open();
        
         
              
         
              FontFactory.register("C:\\windows\\Fonts\\ARIALBD.TTF");
         
              //FontFactory.register("C:\\ARIALUNI.TTF");
         
              StyleSheet
st = newStyleSheet();
         
              st.loadTagStyle("font", "face", "Arial Bold"); 
         
              st.loadTagStyle("body", "encoding", "Identity-H"); 
         
              //st.loadTagStyle("font",
"size", "12"); 
         
              st.loadTagStyle("div", "align", "Left");
         
              st.loadTagStyle("div", "dir", "rtl");
         
              st.loadTagStyle("table", "dir", "rtl");
         
              
         
               
               
              
         
              
         
  
         
              HTMLWorker worker = newHTMLWorker(document);
         
              //System.out.println(content);
         
              StringReader
stringReader = newStringReader(content);   //content is the string containing 
html code
         
              
         
              ArrayList
pl = HTMLWorker.parseToList(stringReader, st);
         
              
         
              for(intk = 0; k < pl.size(); ++k)
         
              { 
         
               
      PdfPTable tbl = (PdfPTable) ((Element)pl.get(k));
         
               
      tbl.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);
         
               
      document.add(tbl);
         
              System.out.println(((Element)pl.get(k)).toString());}
         
              document.close(); 



Best Regards,
Fitouri Abdelaziz  This message and any attachments (the "message") is intended 
for the sole use of its addressee.        
If you are not the addressee, please immediately notify the sender and then 
destroy the message. As this message and/or any attachments may have been 
altered without our knowledge, its content is not legally binding on PicoSoft.  
All rights reserved.    www.picosoft.biz   
------------------------------------------------------------------------------
RSA® Conference 2012
Save $700 by Nov 18
Register now!
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php
------------------------------------------------------------------------------
RSA&#174; Conference 2012
Save $700 by Nov 18
Register now&#33;
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to