Add text using Aspose.PDF for .NET - alignment for Arabic content

Hi,

I am using Aspose.pdf.dll version 4.7.0.0 for .net in one of our products. The website has multi lingual feature and generates pdf reports in Arabic language.

This pdf content is structured with Aspose.Pdf.Table, Rows and cells. We add segments to the Text object and then add the text to the table cell.

For Arabic language the text has to be directed as Right to Left (RTL). So I use the property “IsRightToLeft = true” for the segments. This property, is moving the text on to the right hand side of the table cell; but I want the text to be on the left side of the but still to have the direction as RTL.

Please suggest me how to achieve this in the version 4.7.0.0 of Aspose.pdf for .Net.

Hello Venkateshwar,

Thanks for using our products.

I have tested the scenario and I am able to notice that even we apply the text alignment information for table cell as Left, the contents are being displayed as Right aligned. For the sake of correction, I have logged this problem as PDFNET-24955 in our issue tracking system and will further look into the details of this problem. We apologize for your inconvenience.

However as a workaround, please try using cell.Padding.Right property to set the alignment of text as left aligned. Please take a look over the attached PDF document that I have generated where table ColumnWidth is 150 and I have specified Cell.Padding.Right information as 50.

In case you have any further query, please feel free to contact.

Hi Nayyer Shahbaz,



My requirement is not just to move a statement or line to left side. I
have to print the Arabic text, this has to be right to left aligned
(Arabic text style). For this I cannot give any defined padding. It has
to be as natural as we right Arabic from right side to left side. Please
see the sample of my requirement in the attached screen
(arabic_articleviewpdf_correct.jpg).



The same thing was working fine with the earlier versions 3.4.0 and 3.0.2. The version 4.7.0 is having this problem.



Please let me know for a different approach, the solution you suggested
is not feasible in my case. One of the reasons is that, the statement can be
of 100 lines, so in this case each lines seems to be applied with the
padding, please see the attached pdf for sample view (paddingtest.jpg).



Your help is much appreciated on this.



Thanks and Regards

Venkat

This is in continuation to my earlier post (289274).



I also noticed when comparing the Arabic content on the pdf
(Aspose.pdf.dll version 4.7.0.0) with the content on web browser
(Aspose.pdf.dll version 3.4.0.0), it seems like the new version is
following bottom to top writing style, where as the earlier version only
writes right to left on every line individually.



please follow the arrows to compare the both Arabic content, from the
attached and let me know your views. The top content is the web browser
content and the bottom content is the pdf version content.


sample code i use.
Text _text = new Text();

Segment seg;

TextInfo txtinfo = new TextInfo();

txtinfo.Alignment = AlignmentType.Left;

txtinfo.IsRightToLeft = true;

txtinfo.IsUnicode = true;

for (int i = 0; i < segments.Length; i++)

{

seg = _text.Segments.Add();

seg.TextInfo = txtinfo;

seg.Content = segments[i].Content;

seg.DateFormat = segments[i].DateFormat;

seg.TextInfo.Alignment = AlignmentType.Left;

_text.TextInfo.Alignment = AlignmentType.Left;

}

int _paraID = cell.Paragraphs.Count + 1;

_text.ID = “para” + _paraID.ToString();

cell.DefaultCellTextInfo.Alignment = AlignmentType.Left;

cell.Alignment = AlignmentType.Left;

cell.Paragraphs.Add(_text);



Let me know your findings on this, this issue is with respect to the version 4.7.0.0.
Please provide a work around for this alignment.



Regards

Venkat

Hi Nayyer Shahbaz,

Finally I was able to achieve the alignment to left for the Arabic content.

You have try this way.
Text txt = new Text();
Segment seg = txt.Segments.Add();
seg.Content = “sample text”;
seg.TextInfo.IsRightToLeft = true;
txt.TextInfo.Alignment = AlignmentType.Right;
//finally add this to the cell object for a table row.
cell.Paragraphs.Add(txt);

You can get the text directed a RTL (Right to Left) and the alignment onto the left hand side of the screen.

Can you please clarify me with the below difference in declaring the segment.
Segment seg = new Segment(): then adding it to the Text instance.

vs

Text txt = new Text();
Segment seg = txt.Segments.Add();

Thanks and Regards
Venkat

Hello Venkat,

Thanks for sharing the details about the issue.

I have tested the scenario and I am able to notice that in latest release version (v5.0.0) the Arabic text is being added in Bottom to Top approach. I have logged this problem as PDFNET-25030 in our issue tracking system.

Concerning to your query on difference between,

Text txt1 = new Text();
Segment seg = new Segment();
text1.Segments.Add(seg);

and

Text txt = new Text();
Segment seg = txt.Segments.Add();

both the statements have same effect. In fact the second approach is much encouraged as it saves extra code lines.

Besides this, I have spent some extra time in understanding the actual Right to Left alignment of the text. Can you please take a look over the attached PDF document and share that as per your requirements, the last line should start from Right edge of the table cell and should go to left side or the output is correct ? I have tested the scenario with Aspose.Pdf for .NET 5.0.0 while using the following code line to add Arabic text.

seg0.Content = "يَجِبُ عَلَى الإنْسَانِ أن يَكُونَ أمِيْنَاً وَصَادِقَاً مَعَ نَفْسِهِ وَمَعَ أَهْلِهِ وَجِيْرَانِهِ وَأَنْ يَبْذُلَ كُلَّ جُهْدٍ فِي إِعْلاءِ شَأْنِ الوَطَنِ وَأَنْ يَعْمَلَ عَلَى . ";

Hi Nayyer Shahbaz,

In your pdf the content is RTL (Right to Left) directed, this as per the Arabic styling, this is correct.
If the last line starts from the Right most of the cell then the alignment of the content is described as Right aligned.
This is not my requirement. The alignment has to be left hand side, so it seems to be correct. But the cutting edge here is the bottom to top writing of the Arabic text. So, if the Arabic readers starts reading each line in this paragraph as a individual line and not as a paragraph then the readability can be a problem.

This was not the case in the earlier version, this problem introduced in the 4.7.0.0 and 5.0.0.0 version dlls. May be ask any Arabic reader to read both the contents in the my bottom_top.jpg and they can suggest better.

Also one new doubt raised, please refer to the arabic_articleviewpdf_correct.jpg in the earlier post. You can find some English and numeric content in between the Arabic text. “Sagem Wireless” and “401” (please closely observe as the image might not be clear). How about these characters, do we need to reverse them as per Arabic reading (I mean some thing like this… wireless Sagem OR sseleriW megaS and 104"), so that when the Arabic reader reads the entire content in a flow he should not get diversion to read from left for these words/numbers.

Please advice. have you got this kind of reporting any time earlier.
Your help at the earliest is much appreciated.

Hello Venkat,

Sorry for replying you late.

As shared earlier, the problem of writing Arabic text in bottom-to-top manner is logged in our issue tracking system as PDFNET-25030. We will definitely investigate the reasons of this problem and will keep you updated on the status of correction. However concerning to your other query on rendering English and numeric text, they should be displayed in their normal order as present in image. We read the Arabic text is Right to left approach and if it contains English or numeric text, the user can easily switch his context to read from Left-to-Right. In case we reverse the order of characters, no one can read the sentences.

In case you have any further query, please feel free to contact. We apologize for your inconvenience.

Hi,

Can you please let me know the status of PDFNET-25030 bug? The issue here is that the arabic text is getting dispalyed from bottom to top when RTL is applied. This issue was not present in the earlier versions of Aspose PDF. We need this fix at the earliest as we have migrated to 5.0 version and this issue is pending for us to be production ready.

Any updates on this is highly appreciated!!


Hello Venkat,

I am afraid the issue is not yet resolved. However, I have requested the development team to share its ETA. More along I have also intimated that this problem is holding the product so it's priority should be High. As soon as I have some updates regarding its resolution, I would be more than happy to share this information with you. We apologize for your inconvenience.

Hi Nayyer,

Can you please let me know of a date when we can expect a fix for the issue PDFNET-25030? This issue is existing from PDF 4.0 onwards. When we have tested with 3.4.0.0 dll and the RTL direction gets applied properly. We cannot go back and use 3.4.0.0 version as there are lot of fixes made in the newer release of Aspose PDF.

Any updates regarding this is highly appreciated. We hardly have any days left for our product to be released.

Thanks.

Hi,

Thanks for your patience.

I am pleased to inform you that the issue reported earlier has been resolved. I hope you will get the hotfix in a day or two. Please be patient and spare us little time. We are sorry for this inconvenience.

Thanks Nayyer. Please let me know once the fix is released.

The issues you have found earlier (filed as 25030) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

Hi Nayyer,

Sorry to say, but we still have an open issue with the latest dll for Arabic support.
<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>AR-SA</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:DontVertAlignCellWithSp/>
<w:DontBreakConstrainedForcedTables/>
<w:DontVertAlignInTxbx/>
<w:Word11KerningPairs/>
<w:CachedColBalance/>
</w:Compatibility>
<w:DoNotOptimizeForBrowser/>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman";}

<![endif]–>

The numbers and non-arabic text are reversed, i.e.., 2004 is coming up like 4002. Similarly if there is some English text, those characters are also reversed i.e.., "Document" to "tnemucoD".

Can you please look into this issue and give us an estimate on when this can be fixed?

Thanks.

Hello Naresh,

Thanks for your patience.

As share on other post 295346, the problem has been logged in our issue tracking system as PDFNET-25909. As soon as the solution becomes available, we would be more than happy to update you with the status of correction. We apologize for your inconvenience.

Hello Naresh,

Our development team is still working get PDFNET-25909 resolved and I am afraid this problem is not yet fixed. However, I have requested the development team to share the ETA regarding its resolution. Please be patient and spare us little time. We apologize for your inconvenience.

Ok, thank you. But please keep us updated on the progress of the issue.

Hi Nayyer,


Any updates on PDFNET-25909? We are running out of time and we also need time to test the fix provided by you before using it.



Thanks,

Naresh

Hi Nayyer,

We haven’t received any communication from Aspose yet. This fix is highly important for us as arabic content is going to be used by a large number of customer. We hardly have 5 days to go to production. This issue (PDF-25909) is holding us back. Please expedite this issue.

Thanks,
Naresh