FieldSymbolCharacterCode Property |
Namespace: Aspose.Words.Fields
Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Insert a SYMBOL field to display a symbol, designated by a character code FieldSymbol field = (FieldSymbol)builder.InsertField(FieldType.FieldSymbol, true); // The ANSI character code "U+00A9", or "169" in integer form, is reserved for the copyright symbol field.CharacterCode = 0x00a9.ToString(); field.IsAnsi = true; Assert.AreEqual(" SYMBOL 169 \\a", field.GetFieldCode()); builder.Writeln(" Line 1"); // In Unicode, the "221E" code is reserved for ths infinity symbol field = (FieldSymbol)builder.InsertField(FieldType.FieldSymbol, true); field.CharacterCode = 0x221E.ToString(); field.IsUnicode = true; // Change the appearance of our symbol // Note that some symbols can change from font to font // The full list of symbols and their fonts can be looked up in the Windows Character Map field.FontName = "Calibri"; field.FontSize = "24"; // A tall symbol like the one we placed can also be made to not push down the text on its line field.DontAffectsLineSpacing = true; Assert.AreEqual(" SYMBOL 8734 \\u \\f Calibri \\s 24 \\h", field.GetFieldCode()); builder.Writeln("Line 2"); // Display a symbol from the Shift-JIS, also known as the Windows-932 code page // With a font that supports Shift-JIS, this symbol will display "あ", which is the large Hiragana letter "A" field = (FieldSymbol)builder.InsertField(FieldType.FieldSymbol, true); field.FontName = "MS Gothic"; field.CharacterCode = 0x82A0.ToString(); field.IsShiftJis = true; Assert.AreEqual(" SYMBOL 33440 \\f \"MS Gothic\" \\j", field.GetFieldCode()); builder.Write("Line 3"); doc.Save(ArtifactsDir + "Field.SYMBOL.docx");