FieldCitation
Contents
[
Hide
]FieldCitation class
Implements the CITATION field.
To learn more, visit the Working with Fields documentation article.
public class FieldCitation : Field
Constructors
| Name | Description |
|---|---|
| FieldCitation() | The default constructor. |
Properties
| Name | Description |
|---|---|
| AnotherSourceTag { get; set; } | Gets or sets a value that matches the Tag element’s value of another source to be included in the citation. |
| DisplayResult { get; } | Gets the text that represents the displayed field result. |
| End { get; } | Gets the node that represents the field end. |
| Format { get; } | Gets a FieldFormat object that provides typed access to field’s formatting. |
| FormatLanguageId { get; set; } | Gets or sets the language ID that is used in conjunction with the specified bibliographic style to format the citation in the document. |
| 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). |
| LocaleId { get; set; } | Gets or sets the LCID of the field. |
| PageNumber { get; set; } | Gets or sets a page number associated with the citation. |
| Prefix { get; set; } | Gets or sets a prefix that is prepended to the citation. |
| 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. |
| SourceTag { get; set; } | Gets or sets a value that matches the Tag element’s value of the source to insert. |
| Start { get; } | Gets the node that represents the start of the field. |
| Suffix { get; set; } | Gets or sets a suffix that is appended to the citation. |
| SuppressAuthor { get; set; } | Gets or sets whether the author information is suppressed from the citation. |
| SuppressTitle { get; set; } | Gets or sets whether the title information is suppressed from the citation. |
| SuppressYear { get; set; } | Gets or sets whether the year information is suppressed from the citation. |
| virtual Type { get; } | Gets the Microsoft Word field type. |
| VolumeNumber { get; set; } | Gets or sets a volume number associated with the citation. |
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). |
| virtual 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
Inserts the contents of the Source element with a specified Tag element using a bibliographic style.
Examples
Shows how to work with CITATION and BIBLIOGRAPHY fields.
// Open a document containing bibliographical sources that we can find in
// Microsoft Word via References -> Citations & Bibliography -> Manage Sources.
Document doc = new Document(MyDir + "Bibliography.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Write("Text to be cited with one source.");
// Create a citation with just the page number and the author of the referenced book.
FieldCitation fieldCitation = (FieldCitation)builder.InsertField(FieldType.FieldCitation, true);
// We refer to sources using their tag names.
fieldCitation.SourceTag = "Book1";
fieldCitation.PageNumber = "85";
fieldCitation.SuppressAuthor = false;
fieldCitation.SuppressTitle = true;
fieldCitation.SuppressYear = true;
Assert.That(fieldCitation.GetFieldCode(), Is.EqualTo(" CITATION Book1 \\p 85 \\t \\y"));
// Create a more detailed citation which cites two sources.
builder.InsertParagraph();
builder.Write("Text to be cited with two sources.");
fieldCitation = (FieldCitation)builder.InsertField(FieldType.FieldCitation, true);
fieldCitation.SourceTag = "Book1";
fieldCitation.AnotherSourceTag = "Book2";
fieldCitation.FormatLanguageId = "en-US";
fieldCitation.PageNumber = "19";
fieldCitation.Prefix = "Prefix ";
fieldCitation.Suffix = " Suffix";
fieldCitation.SuppressAuthor = false;
fieldCitation.SuppressTitle = false;
fieldCitation.SuppressYear = false;
fieldCitation.VolumeNumber = "VII";
Assert.That(fieldCitation.GetFieldCode(), Is.EqualTo(" CITATION Book1 \\m Book2 \\l en-US \\p 19 \\f \"Prefix \" \\s \" Suffix\" \\v VII"));
// We can use a BIBLIOGRAPHY field to display all the sources within the document.
builder.InsertBreak(BreakType.PageBreak);
FieldBibliography fieldBibliography = (FieldBibliography)builder.InsertField(FieldType.FieldBibliography, true);
fieldBibliography.FormatLanguageId = "5129";
fieldBibliography.FilterLanguageId = "5129";
fieldBibliography.SourceTag = "Book2";
Assert.That(fieldBibliography.GetFieldCode(), Is.EqualTo(" BIBLIOGRAPHY \\l 5129 \\f 5129 \\m Book2"));
doc.UpdateFields();
doc.Save(ArtifactsDir + "Field.CITATION.docx");
See Also
- class Field
- namespace Aspose.Words.Fields
- assembly Aspose.Words