FieldBibliography

FieldBibliography class

Implements the BIBLIOGRAPHY field.

public class FieldBibliography : Field

Constructors

Name Description
FieldBibliography() The default constructor.

Properties

Name Description
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 to format the bibliographic sources 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.
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

Inserts the contents of the document’s Bibliography part in 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.AreEqual(" CITATION  Book1 \\p 85 \\t \\y", fieldCitation.GetFieldCode());

// 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.AreEqual(" CITATION  Book1 \\m Book2 \\l en-US \\p 19 \\f \"Prefix \" \\s \" Suffix\" \\v VII", fieldCitation.GetFieldCode());

// 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 = "1124";

Assert.AreEqual(" BIBLIOGRAPHY  \\l 1124", fieldBibliography.GetFieldCode());

doc.UpdateFields();
doc.Save(ArtifactsDir + "Field.CITATION.docx");

See Also