Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Tue Nov 12, 2019 5:13 pm

Hi,

I'm constructing a word document with simple table structures from database(3 or 4 columns in each table). I need to produce this document in Arabic and English. Since Arabic is Right-To-Left, my tables are displaying incorrectly. 3rd column in English should be 1st column in Arabic.

I know we can use Bidi format for paragraph/textrange in single cell. Is there a way I can apply this to table.

Or do I need to write seperate layout for Arabic and English? Any help is appreciated.

I'm using the latest nuget packages for Spire.Office.

Thanks.

santuvssantu
 
Posts: 98
Joined: Fri Feb 12, 2016 5:21 pm

Wed Nov 13, 2019 9:45 am

Hi,

Thanks for your inquiry.
Based on your information, in your table some columns have Arabic text which is Right-To-Left layout while some columns have English text. And there is no direct way to set all the text in whole table as Right-To-Left layout. In your case, you need to write separately layout for Arabic text and English text. Below is the code snippet for your kind reference:

Code: Select all
            for (int i = 0; i <data.Length ; i++)
            {
                //Set the first column text with Bidi format.
                Paragraph para = table.Rows[i].Cells[0].AddParagraph();
                para.Format.IsBidi = true;
                TextRange TR = para.AppendText(data[i]);

                //Set the Bidi format for the text.
                TR.CharacterFormat.Bidi = true;
            }

            for (int i = 0; i < data1.Length; i++)
            {
                //Fill the third column with English string.
                Paragraph para = table.Rows[i].Cells[2].AddParagraph();
                TextRange TR = para.AppendText(data1[i]);
            }


If the code couldn't solve your issue, please offer us the following information for further investigation.
1. Your input data.
2. Your desired result file.

You could upload them here or send us(support@e-iceblue.com) via email.

Best wishes,
Amber
E-iceblue support team
User avatar

Amber.Gu
 
Posts: 525
Joined: Tue Jun 04, 2019 3:16 am

Wed Nov 13, 2019 10:31 am

Hi Amber, thanks for your response on this. Sorry that my question was little ambiguous.
My database table has couple of columns where few rows are in English and few rows are in Arabic for that columns.
I need to produce an English pdf with English rows. Likewise seperate pdf for Arabic rows.

I wrote code to filter my records based on language and constructing the pdf. English pdf works fine. Arabic is displaying correct values, how ever columns are in left to right fashion instead of right to left.

Some of the code from my cs file.

Code: Select all
var row = table.AddRow(false, 4);
               
                row.Cells[0].CellWidthType = CellWidthType.Point;
                row.Cells[0].Width = 60f;
 
                var paragraph = row.Cells[0].AddParagraph();

                var progName = "my text"; //English or Arabic depends on input language

                TextRange range = paragraph.AppendText(progName); 

                var paragraph2 = row.Cells[1].AddParagraph();
                paragraph2.AppendHTML("other text"); //English or Arabic depends on input language
             
                if (mylanguage == "Arabic")
                {
                    paragraph.Format.IsBidi = true;
                    paragraph2.Format.IsBidi = true;
                }
               
                table.ApplyHorizontalMerge(row.GetRowIndex(), 1, 3);



Can I apply Bidi at table level or any other setting so it generates layout dynamically? I send either English or Arabic for my method not both at same time.

Hope this clarifies my situation.

santuvssantu
 
Posts: 98
Joined: Fri Feb 12, 2016 5:21 pm

Thu Nov 14, 2019 2:21 am

Hi,

Thanks for your reply.
Do you want to set the table column layout as RTL or LTR? If so, below is the code for you.

Code: Select all
            //Set the Bidi format for table. The table columns will display as Right-To-Left.
            table.TableFormat.Bidi = true;


If I misunderstand, please offer us the following information for further investigation.
1. Your result file.
2. Your desired result file.

You could upload them here or send us(support@e-iceblue.com) via email.

Best wishes,
Amber
E-iceblue support team
User avatar

Amber.Gu
 
Posts: 525
Joined: Tue Jun 04, 2019 3:16 am

Thu Nov 14, 2019 12:55 pm

MyFiles.zip
Thanks,

I tried below, but it's not working
Code: Select all
 var table = doc.LastSection.AddTable(false);
                 
                var width = new PreferredWidth(WidthType.Percentage, 100);
                table.PreferredWidth = width;

                foreach (var value in documents)
                {
                    var row = table.AddRow(false, 2);
                    row.Cells[0].CellWidthType = CellWidthType.Point;
                    row.Cells[0].Width = 60f;
 
                    var paragraph = row.Cells[0].AddParagraph();
 
                    TextRange range = paragraph.AppendText(value.text1);
                    range.CharacterFormat.FontName = "Times New Roman";
                    range.CharacterFormat.FontSize = 10;
                    paragraph.Format.HorizontalAlignment = HorizontalAlignment.Left;

                    var paragraph2 = row.Cells[1].AddParagraph();
                    paragraph2.AppendHTML(value.text2);
                   
                   
                        paragraph.Format.IsBidi = true;
                        paragraph2.Format.IsBidi = true;
                        row.RowFormat.Bidi = true;
                   }
                table.TableFormat.Bidi = true;



This doesnt give me correct. value.text1 is displaying as first column, value.text2 is displaying as second. It should be reverse for Arabic.

Update: On a second glance, I understand Word is displaying fine RTL format, however when I saved that docx to pdf, it shows as LTR.

Code: Select all
var parms = new SP.ToPdfParameterList()
            {
                IsEmbeddedAllFonts = true
            };

            SP.Document document = new SP.Document();
            document.LoadFromFile(fileName + ".docx");
            //doc.SaveToFile(fileName + ".pdf", SP.FileFormat.PDF);
            ////Convert Word to PDF
            document.SaveToFile(fileName + ".pdf", parms);



Attached are my docx and pdf.

santuvssantu
 
Posts: 98
Joined: Fri Feb 12, 2016 5:21 pm

Fri Nov 15, 2019 11:23 am

Hi,

Thanks for your information.
I tested your file with Spire.Office Platinum (DLL Only) Version:4.10.0 and didn't find the same issue as yours, but I found the Arabic text direction in the table will be changed from RTL to LTR after converting the Word file to Pdf file on my side(attached is my result file).
I have logged this issue regarding the text direction into our bug tracking system. Once there is any progress, we will inform you. Sorry for the inconvenience caused.

Best wishes,
Amber
E-iceblue support team
User avatar

Amber.Gu
 
Posts: 525
Joined: Tue Jun 04, 2019 3:16 am

Tue Nov 19, 2019 1:53 pm

Hi,

Do you have an update on this? Can you provide an estimated date when this can be done?

Thanks,
Santhoshi.

santuvssantu
 
Posts: 98
Joined: Fri Feb 12, 2016 5:21 pm

Wed Nov 20, 2019 1:17 am

Hi,

Thanks for your reply.
I checked the state of your issue in our bug tracking system. Sorry that it has not been resolved yet. And sorry there is no ETA now. I have urged our Dev team. Once there is any progress, we will inform you ASAP. Sorry for the inconvenience caused.

Best wishes,
Amber
E-iceblue support team
User avatar

Amber.Gu
 
Posts: 525
Joined: Tue Jun 04, 2019 3:16 am

Wed Nov 20, 2019 1:30 pm

Thank you Amber. We will wait on this.

santuvssantu
 
Posts: 98
Joined: Fri Feb 12, 2016 5:21 pm

Thu Nov 21, 2019 1:03 am

Hi,

Thanks for your reply.
Once there is any progress on this issue, we will inform you ASAP. Sorry for the inconvenience caused.

Best wishes,
Amber
E-iceblue support team
User avatar

Amber.Gu
 
Posts: 525
Joined: Tue Jun 04, 2019 3:16 am

Thu Nov 28, 2019 2:05 pm

Hello Amber,
Could you please give an update on this? We are waiting since two weeks.


thanks,
Santhoshi.

santuvssantu
 
Posts: 98
Joined: Fri Feb 12, 2016 5:21 pm

Fri Nov 29, 2019 1:40 am

Hi,

Thanks for your reply.
I checked the state of your issue in our bug tracking system. Sorry that it has not been resolved yet. I have improved the priority of this issue.
Once there is any progress, we will inform you ASAP. Sorry for the inconvenience caused.

Best wishes,
Amber
E-iceblue support team
User avatar

Amber.Gu
 
Posts: 525
Joined: Tue Jun 04, 2019 3:16 am

Mon Dec 02, 2019 9:56 am

Thanks,
We are due for a prod release and this issue is effecting us major. Any quick response is much appreciated.

On another note, Could you please provide your contact card so our HR partner can reach out for license renewal ?


Thanks,
Santhoshi.

santuvssantu
 
Posts: 98
Joined: Fri Feb 12, 2016 5:21 pm

Mon Dec 02, 2019 10:14 am

Hi,

Thanks for your reply.
I checked the state of your issue in our bug tracking system. Sorry that it has not been resolved yet. I have improved your issue to the highest priority. Once there is any progress, we will inform you ASAP. Sorry for the inconvenience caused.
And you could contact our sales team(sales@e-iceblue.com) for license renewal.

Best wishes,
Amber
E-iceblue support team
User avatar

Amber.Gu
 
Posts: 525
Joined: Tue Jun 04, 2019 3:16 am

Thu Dec 05, 2019 7:31 am

Hi Amber,

Thanks for the information. We are due for an User Acceptance release this friday and appreciate if it can be resolved quickly

Thanks,
Santhoshi.

santuvssantu
 
Posts: 98
Joined: Fri Feb 12, 2016 5:21 pm

Return to Spire.Doc