Hello,
Thanks
for your attention, but encoding = BaseFont.IDENTITY_H is mandatory for RTL
strings otherwise nothing will be displayed on the screen (just an empty space)
and PdfWriter.RUN_DIRECTION_RTL should be applied too to rotate characters.
Without PdfWriter.RUN_DIRECTION_RTL you will see "tac" instead of
"cat". So there is no choice here. It doesn't matter css direction:rtl is
set or not. Without BaseFont.IDENTITY_H and PdfWriter.RUN_DIRECTION_RTL, the
result will be nothing or some garbage for RTL data.
Best regards,
Vahid
________________________________
From: Balder VC <li...@redlab.be>
To: Post all your questions about iText here
<itext-questions@lists.sourceforge.net>
Sent: Saturday, December 10, 2011 5:20 PM
Subject: [iText-questions] Fwd: Re: XMLWorker & RTL
Seems my previous mail did not get through
-------- Original Message --------
Subject: Re: [iText-questions] XMLWorker & RTL
Date: Sat, 10 Dec 2011 14:30:35 +0100
From: Balder VC <li...@redlab.be>
Organisation: redlab.be
To: itext-questions@lists.sourceforge.net
Hi
Thanks for bringing that to attention. At the moment rtl is not
supported.
I would not rely on a regex to determine the text direction after
all perhaps some one intend to display it in the other run
direction?
I would opt for using CSS to set the run direction. Just like in
html
{
direction:rtl;
}
the encoding should be settable in the same way, we can add an
xmlworker specific css property for that. Forcing .CP1252 is not a
good idea, that's right.
Thanks for the idea
ps: please don't hijack other threads, write a new message for a new
topic, I almost mist this mail.
On 8/12/2011 22:34, Vahid Nasiri wrote:
Hello,
>In iTextSharp.tool.xml.css.apply.ChunkCssApplier class, String encoding is
>hardcoded to BaseFont.CP1252.
>It's easy to detect right to left languages data:
>
> static readonly Regex MatchArabicHebrew = new
>Regex(@"[\u0600-\u06FF,\u0590-\u05FF]+", RegexOptions.IgnoreCase |
>RegexOptions.Compiled);
> public static bool IsRtl(string data)
> {
> if (string.IsNullOrEmpty(data)) return false;
> return MatchArabicHebrew.IsMatch(data);
> }
>
>And then we can improve Apply method of ChunkCssApplier class for instance:
>
> public Chunk Apply(Chunk c, Tag t)
> {
> String fontName = null;
> String encoding = BaseFont.CP1252;
> if (IsRtl(c.Content)) encoding = BaseFont.IDENTITY_H;
>
>Also
run_direction should be set for PdfPCell and other similar elements to RTL.
>Ex. iTextSharp.tool.xml.html.table.TableData class
>
>public
override IList<IElement> End(IWorkerContext
ctx, Tag tag, IList<IElement> currentContent) {
> HtmlCell cell = new HtmlCell();
> IList<IElement> l = new List<IElement>(1);
> foreach (IElement e in currentContent) {
>
> if(e is Chunk)
> if (IsRtl(((Chunk)e).Content))
> {
> cell.RunDirection = PdfWriter.RUN_DIRECTION_RTL;
> }
>
>
--
twitter
redlab-log
------------------------------------------------------------------------------
Learn Windows Azure Live! Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for
developers. It will provide a great way to learn Windows Azure and what it
provides. You can attend the event by watching it streamed LIVE online.
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
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
------------------------------------------------------------------------------
Learn Windows Azure Live! Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for
developers. It will provide a great way to learn Windows Azure and what it
provides. You can attend the event by watching it streamed LIVE online.
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
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