My c# code tries to replace in a PDF file the string "TEST POR MARCA RETOÑO" by "TEST POR MARCA ENERO". But after the string is replaced, the accent of the letter "Ñ" is maintained as shown in the image. How can I fix this problem?
Here adding in the dictionary the strings and calling the replace function:
- Code: Select all
dictionary.Add("TEST POR MARCA RETOÑO", "TEST POR MARCA ENERO");
SpireFintTextInPDFAndReplaceItNombreProducto(doc, dictionary);
Here the replace function:
- Code: Select all
public static void SpireFintTextInPDFAndReplaceItNombreProducto(PdfDocument documents, Dictionary<string, string> dictionary)
{
PdfTextFind[] result = null;
foreach (var word in dictionary)
{
foreach (PdfPageBase page in documents.Pages)
{
try
{
result = page.FindText(word.Key, TextFindParameter.WholeWord).Finds;
int i = 0;
foreach (PdfTextFind find in result)
{
if (i == 0)
find.ApplyRecoverString(word.Value, SystemColors.ControlLight, true);
else find.ApplyRecoverString(word.Value, System.Drawing.Color.White, true);
i++;
}
}
catch (Exception ex)
{
continue;
}
}
}
}
Please, see the attached file where you can see the ressult. As you can check, the accent of "Ñ" remains.
Thanks in advance for your help.