ParagraphAppendField Method (String, String) |
Namespace: Aspose.Words
// Create a blank document and get its first paragraph Document doc = new Document(); Paragraph para = doc.FirstSection.Body.FirstParagraph; // Choose a field by FieldType, append it to the end of the paragraph and update it para.AppendField(FieldType.FieldDate, true); // Append a field with a field code created by hand para.AppendField(" TIME \\@ \"HH:mm:ss\" "); // Append a field that will display a placeholder value until it is updated manually in Microsoft Word // or programmatically with Document.UpdateFields() or Field.Update() para.AppendField(" QUOTE \"Real value\"", "Placeholder value"); // We can choose a node in the paragraph and insert a field // before or after that node instead of appending it to the end of a paragraph para = doc.FirstSection.Body.AppendParagraph(""); Run run = new Run(doc) { Text = " My Run. " }; para.AppendChild(run); // Insert a field into the paragraph and place it before the run we created doc.BuiltInDocumentProperties["Author"].Value = "John Doe"; para.InsertField(FieldType.FieldAuthor, true, run, false); // Insert another field designated by field code before the run para.InsertField(" QUOTE \"Real value\" ", run, false); // Insert another field with a place holder value and place it after the run para.InsertField(" QUOTE \"Real value\"", " Placeholder value. ", run, true); doc.Save(ArtifactsDir + "Paragraph.InsertField.docx");