FieldSymbol
Contents
[
Hide
]FieldSymbol class
Implements a SYMBOL field.
To learn more, visit the Working with Fields documentation article.
public class FieldSymbol : Field
Constructors
Name | Description |
---|---|
FieldSymbol() | The default constructor. |
Properties
Name | Description |
---|---|
CharacterCode { get; set; } | Gets or sets the character’s code point value in decimal or hexadecimal. |
DisplayResult { get; } | Gets the text that represents the displayed field result. |
DontAffectsLineSpacing { get; set; } | Gets or sets whether the character retrieved by the field affects the line spacing of the paragraph. |
End { get; } | Gets the node that represents the field end. |
FontName { get; set; } | Gets or sets the name of the font of the character retrieved by the field. |
FontSize { get; set; } | Gets or sets the size in points of the font of the character retrieved by the field. |
Format { get; } | Gets a FieldFormat object that provides typed access to field’s formatting. |
IsAnsi { get; set; } | Gets or sets whether the character code is interpreted as the value of an ANSI character. |
IsDirty { get; set; } | Gets or sets whether the current result of the field is no longer correct (stale) due to other modifications made to the document. |
IsLocked { get; set; } | Gets or sets whether the field is locked (should not recalculate its result). |
IsShiftJis { get; set; } | Gets or sets whether the character code is interpreted as the value of a SHIFT-JIS character. |
IsUnicode { get; set; } | Gets or sets whether the character code is interpreted as the value of a Unicode character. |
LocaleId { get; set; } | Gets or sets the LCID of the field. |
Result { get; set; } | Gets or sets text that is between the field separator and field end. |
Separator { get; } | Gets the node that represents the field separator. Can be null . |
Start { get; } | Gets the node that represents the start of the field. |
virtual Type { get; } | Gets the Microsoft Word field type. |
Methods
Name | Description |
---|---|
GetFieldCode() | Returns text between field start and field separator (or field end if there is no separator). Both field code and field result of child fields are included. |
GetFieldCode(bool) | Returns text between field start and field separator (or field end if there is no separator). |
Remove() | Removes the field from the document. Returns a node right after the field. If the field’s end is the last child of its parent node, returns its parent paragraph. If the field is already removed, returns null . |
Unlink() | Performs the field unlink. |
Update() | Performs the field update. Throws if the field is being updated already. |
Update(bool) | Performs a field update. Throws if the field is being updated already. |
Remarks
Retrieves the character whose code point value is specified in decimal or hexadecimal.
Examples
Shows how to use the SYMBOL field.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Below are three ways to use a SYMBOL field to display a single character.
// 1 - Add a SYMBOL field which displays the © (Copyright) symbol, specified by an ANSI 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");
// 2 - Add a SYMBOL field which displays the ∞ (Infinity) symbol, and modify its appearance:
field = (FieldSymbol)builder.InsertField(FieldType.FieldSymbol, true);
// In Unicode, the infinity symbol occupies the "221E" code.
field.CharacterCode = 0x221E.ToString();
field.IsUnicode = true;
// Change the font of our symbol after using the Windows Character Map
// to ensure that the font can represent that symbol.
field.FontName = "Calibri";
field.FontSize = "24";
// We can set this flag for tall symbols to make them not push down the rest of the text on their line.
field.DontAffectsLineSpacing = true;
Assert.AreEqual(" SYMBOL 8734 \\u \\f Calibri \\s 24 \\h", field.GetFieldCode());
builder.Writeln("Line 2");
// 3 - Add a SYMBOL field which displays the あ character,
// with a font that supports Shift-JIS (Windows-932) codepage:
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");
See Also
- class Field
- namespace Aspose.Words.Fields
- assembly Aspose.Words