Detecting and creating Symbol special characters

I am using Aspose Word to convert a docx file into our xml standard. All is well other than i cant seem to find a way to capture special characters.
So Pi characters inserted using the Insert/Symbol character panel.

Essentially I want to capture this code so I can create an xml element defining the Font and character code.

I need this as at a point in the future I need to convert the xml back into a docx format and consequently expand my back to a word special character.

Can you help me understand how to detect these codes and also how to insert them.

Appreciate anything

Jan Urbanski

Hi Jan,

Thanks for your inquiry. I am checking with this scenario and will get back to you soon.

Best regards,

Hi Jan,

Thank you for being patient.

In order to insert a Symbol using Aspose.Words, you must know it’s hex or decimal code. You can find the Symbol character code inside Insert Symbol dialogue in Microsoft Word. Once you know the Symbol code, you can use the following code to insert it using Aspose.Words:

DocumentBuilder builder = new DocumentBuilder();
// Insert PI symbol. Character code of PI is '220F'
builder.Write("" + (char) 0x220F);

Again, for detecting/capturing the Symbol, you need to write a mechanism for searching characters by their codes. For example, you could loop through all Run nodes in your document and find presence of symbol character by comparing it with it’s hex code.

Moreover, please note that each font can has symbols i.e. the PI symbol can be formatted with TimesNewRoman or with Arial. So, you can retrieve the Font by using Run.Font property.

Best regards,

Thanks very much- That helps me out


I am having a similar problem with inserting special ASCII characters. When I insert the characters during the mail merge without special handling, the characters appear as the proper symbol. See the “WithoutRed” attachment.
However, my requirement is that the symbols are red. So, I am using the follow code to change the font color to red:

Public Class HandleMergeFields
    Implements IFieldMergingCallback
    Private Sub FieldMerging(ByVal e As FieldMergingArgs) Implements IFieldMergingCallback.FieldMerging
        Dim myFieldName As String = e.FieldName
        Dim myFieldValue As String = e.FieldValue.ToString()

        If myFieldValue = "►" Then
            Dim builder As New DocumentBuilder(e.Document)
            builder.MoveToField(e.Field, True)
            builder.Font.Color = Color.Red
            e.Text = String.Empty
        End If
    End Sub
End Class

Of course, when I am performing the merge, I trigger this callback as follows:

doc.MailMerge.FieldMergingCallback = New HandleMergeFields()

With this technique, I get the WithRed result (the code, not the character appears).

I’ve also attempted to “Write” using CChar function like this (with several variations):

builder.Write("" + CChar("►"))

No luck so far. That simply puts the 1st character of the code in red.

Any suggestions?



Hi James,

Thanks for your inquiry. Could you please attach your input template document and output document (showing the undesired behaviour) here for testing? I will investigate the issue on my side and provide you more information.

Best regards,