Free Support Forum - aspose.com

Issue generating PDF with $S12345 (singapore dollar)

Hi,

We have a report that contains financial information for a singapore company. In the report when representing the financial information if the currency ‘$S12345’ begins in a new line then creation of the PDF is failing. Upon going through you documentation(http://www.aspose.com/documentation/.net-components/aspose.pdf-for-.net/replaceable-symbols.html) $S seems to have a special usage because of which the issue is happening. Below is the sample code to replicate this issue.

// Instantiate an object PDF class
Pdf pdf = new Pdf();
//Create a section in the Pdf object
Aspose.Pdf.Section sec1 = pdf.Sections.Add();

Aspose.Pdf.Text text2 = new Aspose.Pdf.Text();
text2.TextInfo.IsRightToLeft = true;
Aspose.Pdf.Segment seg1 = text2.Segments.Add();
seg1.Content = @“Market capitalisation of listed companies

2192 Number of listed companies

$S763 billion Market capitalisation of listed companies

774 Listings (including China companies)”;

seg1.TextInfo.IsRightToLeft = true;
seg1.TextInfo.IsUnicode = true;

sec1.Paragraphs.Add(text2);

pdf.Save(@“C:\SigaporeDollarIssue.pdf”);

Please let me know how to resolve this issue.

Thanks,
Naresh

Hello Naresh,

<!–[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>ZH-CN</w:LidThemeAsian>
<w:LidThemeComplexScript>AR-SA</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
<w:UseFELayout/>
</w:Compatibility>
<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-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:Arial; mso-bidi-theme-font:minor-bidi;}

<![endif]–>

<span style=“font-family:“Helvetica”,“sans-serif””>Thanks for using our
products.

<span style=“font-family:“Helvetica”,“sans-serif””>I have tested the scenario
and I have managed to reproduce the same problem that when using $S sign, the
output is not correct. For the sake of correction, I have logged this problem as
PDFNEWNET-29380
in our issue tracking system. We will further look into the
details of this problem and will keep you updated on the status of correction.
Please be patient and spare us little time. We apologize for your
inconvenience.

<span style=“font-family:“Helvetica”,“sans-serif””>PS, We have certain special
reserved words starting with $S but we don’t have any special keyword equal to
$S.

Hello Naresh,

Thanks for your patience.

We have further investigated this issue and have observed that the problem is occurring because you are using text2.TextInfo.IsRightToLeft = true; and seg1.TextInfo.IsRightToLeft = true; code lines. Please comment out these lines the resultant PDF will be fine. I have again created a PDF document using Aspose.Pdf for .NET 6.0.0 and I am unable to notice any issue. For your reference, I have attached the resultant PDF that I have generated. Please take a look.

In case you still encounter any problem, please feel free to contact.

[C#]

// Instantiate an object PDF class
Pdf pdf = new Pdf();
//Create a section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf.Sections.Add();
Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text();
// text2.TextInfo.IsRightToLeft = true;
Aspose.Pdf.Generator.Segment seg1 = text2.Segments.Add();
seg1.Content = @"Market capitalisation of listed companies
2192 Number of listed companies
$S763 billion Market capitalisation of listed companies
774 Listings (including China companies)";
// Do not replace the reserved words at runtime
seg1.IsSymbolReplaceable = false;
//seg1.TextInfo.IsRightToLeft = true;
seg1.TextInfo.IsUnicode = true;
sec1.Paragraphs.Add(text2);
pdf.Save(@"d:/pdftest/SigaporeDollarIssue.pdf");

Hi Nayyer,

This issue is not because of RTL properties. Please try the below code:
The issue happens when $S12345 value is on a new line or separated by a tab or at the beginning of a paragraph.

// Instantiate an object PDF class
Pdf pdf = new Pdf();
//Create a section in the Pdf object
Aspose.Pdf.Section sec1 = pdf.Sections.Add();

Aspose.Pdf.Text text2 = new Aspose.Pdf.Text();
Aspose.Pdf.Segment seg1 = text2.Segments.Add();
seg1.Content = @"$S763 Market capitalisation of listed companies

2192 Number of listed companies

$S763 billion Market capitalisation of listed companies

774 Listings (including China companies)";

sec1.Paragraphs.Add(text2);

pdf.Save(@“C:\SigaporeDollarIssuetest.pdf”);

Please let me know if you are still not able to replicate the issue.

Thanks.

Hello Naresh,

Thanks for sharing the code snippet and sorry for replying you late.

I have tried executing the code with Aspose.Pdf for .NET 6.0.0 and as per my observations, the application hangs and PDF document is not generated. Before we proceed further towards its resolution, can you please confirm that you are facing similar problem ?

We are sorry for your inconvenience.