-1

I am reading an arabic localized pdf document in memory using c# and after reading the text i am getting it like this

٩٠/٤٠/٧٣٤١ ٩١/١٠/٦١٠٢

but the correct direction of this text in pdf is ٢٠١٦/٠١/١٩ ١٤٣٧/٠٤/٠٩

Can somebody please guide how can change this text direction to proper direction as it is appearing in pdf.

Edit

This is the function i am using. I am using Devexpress Document server, I am skipping upto line 36 as I do not need the data before line 36.

 private void button1_Click(object sender, EventArgs e)
        {

            using (var documentStream = new FileStream(@"D:\Data\Projects\DotNet\ElectricBillReader\electricbill.pdf", FileMode.Open, FileAccess.Read))
            {
                using (PdfDocumentProcessor documentProcessor = new PdfDocumentProcessor())
                {
                    documentProcessor.LoadDocument(documentStream);

                    using (var sr = new StringReader(documentProcessor.Text))
                    {
                        var counter = 0;
                        string line = string.Empty;
                        do
                        {
                            line = sr.ReadLine();
                            if (counter > 36)
                            {
                                if (line != null)
                                {

                                }
                            }
                            counter++;
                        } while (line!=null);
                    }
                }
            }
        }
Shax
  • 4,207
  • 10
  • 46
  • 62
  • 1
    can you provide some code? – Raskayu Aug 25 '16 at 11:43
  • "Being in the correct order" is a property of the string as a whole, not of the individual characters. When displayed with capable software, the string *will* appear in the right direction. – Jongware Aug 25 '16 at 17:32

2 Answers2

1

You're gonna need a library that implements the Unicode bidirectional algorithm, i'm not aware of any libraries that does this for .NET but there's an effort to port ICU to .NET here

Also, check this out: https://sourceforge.net/projects/nbidi/

amrnablus
  • 237
  • 1
  • 3
  • 12
0

Did you think about just reversing the string?

public static string Reverse( string s )
{
    char[] charArray = s.ToCharArray();
    Array.Reverse( charArray );
    return new string( charArray );
}

Source

Master117
  • 660
  • 6
  • 21