Escaping the dollar sign in Visual C#

If I have text with a dollar sign, it doesn't show properly in Aspose.PDF. Below is a snippet.


string newValue = selectedNode.GetValue("INSP_SUMMARY", 1, 1, 1).Replace("$", "abc");
bottomRows[1].Cells[0].Paragraphs.Add(new Text(newValue));

If newValue is "Jim gave Bill $20 to go to the movies", only "20 to go to the movies" will show up. The dollar sign and everything before that does not show up. I tried using .Replace("$", "$$"), but that didn't work. I even tried "\\$", but that didn't work. I noticed that $D gives the date and $ might be used for other macros. Are there any other special characters that I should be wary of?

Thanks in advance!


This message was posted using Aspose.Live 2 Forum

Hello Bill,

Thanks for considering Aspose.

Please visit the following link for required information on how to Display Currency symbol with table values

I would also recommend you to visit the following link for information on working with Replaceable Symbols

If it does not resolve your problem or you've any further query, please feel free to contact.

Hello Bill,

I've tested the scenario with the following code snippet and I'm unable to notice the problem.

[C#]

Pdf generatedPdf = new Pdf();
Aspose.Pdf.Section sectionSourceText = generatedPdf.Sections.Add();

Aspose.Pdf.Table mytab = new Aspose.Pdf.Table(sectionSourceText);
Aspose.Pdf.Row bottomRows = mytab.Rows.Add();
bottomRows.Cells.Add("I owe John $50 in cash");

TableFormatInfo tfi = new TableFormatInfo();
tfi.CurrencySymbol = "$";
tfi.SymbolBehind = true;
mytab.FormatTableWithFormatInfo(tfi, 0, 0, 1,1);

sectionSourceText.Paragraphs.Add(mytab);
generatedPdf.Save("d:/pdftest/CurrencySymbol_Test.pdf");

I've also attached the resultant PDF. Please take a look.

I tried your example and it works. I took out the TableFormatInfo lines of code, and it still produces “I owe John $50 in cash”, which is a good thing. There may have been a bug in another part of our program. However, I changed “$50” to “$D50”, and no matter if you use TableFormatInfo or not, $D will change to today’s date.

Hello Bill,

Thanks for considering Aspose.

The TableFormatInfo only works in case you are adding some numeric values to the table and want to display the currency symbols beside them. In my above example, the contents of table cell are simply a text string and $ sign will be displayed in table cell even if you comment out the TableFormatInfo code.

However, regarding the issue of displaying current system date, $D is used to display the current system date and its only replaced if you've set the value of IsSymbolReplaceable property of Segment class to true. If you set the property value to false, it will not be replaced over runtime.

I would suggest you to visit the following link for more information on Symbols List and Purpose

Codewarior,

I copied a problem batch of text and used it in the sample solution program. It still causes a problem. I wonder which characters in the text cause the dollar sign and the text before to not appear.

public class TestPDF
{
public TestPDF()
{
Pdf generatedPdf = new Pdf();
Aspose.Pdf.Section sectionSourceText = generatedPdf.Sections.Add();

Aspose.Pdf.Table mytab = new Aspose.Pdf.Table(sectionSourceText);
mytab.ColumnWidths = “270 270”;
Aspose.Pdf.Row bottomRows = mytab.Rows.Add();
bottomRows.Cells.Add();
bottomRows.Cells[0].ColumnsSpan = 1;
bottomRows.Cells[0].Paragraphs.Add(new Text(“Test amount is $50 in cash.\r\n\r\nThe dollar bank is the best place to get $1,000,000 loan.\r\n\r\n$596,293\r\n\r\nI am the #1 fan.”));

TableFormatInfo tfi = new TableFormatInfo();
tfi.CurrencySymbol = “$”;
tfi.SymbolBehind = true;
mytab.FormatTableWithFormatInfo(tfi, 0, 0, 1,1);

sectionSourceText.Paragraphs.Add(mytab);
generatedPdf.Save(“c:/CurrencySymbol_Test.pdf”);
}
}

Hello Bill,

I have tested the issue and I’m able to reproduce the same problem. I have logged it in our issue tracking system as PDFNET-13425. We will investigate this issue in detail and will keep you updated on the status of a correction.

We apologize for your inconvenience.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Hello Bill,

Thanks for your patience.

I'm pleased to inform you that the issue reported earlier has been solved in the attached HotFix. Please try using it and in case you still face any problem, please feel free to contact.

Thanks for your cooperation.

Hi,

As per the Live Support session, you’ve mentioned that the file is inaccessible and you’re able to see some message i.e. unavailable. I think you’re trying to access the file without logging over www.aspose.com server. Please first login over the server because, you can only access the file, once you’re logged in.

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

Thank you for your swift response and for the hotfix. The data displays properly now.

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


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