FieldRDIsPathRelative Property |
Namespace: Aspose.Words.Fields
Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Use a document builder to insert a table of contents and, on the following page, one entry builder.InsertField(FieldType.FieldTOC, true); builder.InsertBreak(BreakType.PageBreak); builder.CurrentParagraph.ParagraphFormat.StyleName = "Heading 1"; builder.Writeln("TOC entry from within this document"); // Insert an RD field, designating an external document that our TOC field will look in for more entries FieldRD field = (FieldRD)builder.InsertField(FieldType.FieldRefDoc, true); field.FileName = "ReferencedDocument.docx"; field.IsPathRelative = true; field.Update(); Assert.AreEqual(" RD ReferencedDocument.docx \\f", field.GetFieldCode()); // Create the document and insert a TOC entry, which will end up in the TOC of our original document Document referencedDoc = new Document(); DocumentBuilder refDocBuilder = new DocumentBuilder(referencedDoc); refDocBuilder.CurrentParagraph.ParagraphFormat.StyleName = "Heading 1"; refDocBuilder.Writeln("TOC entry from referenced document"); referencedDoc.Save(ArtifactsDir + "ReferencedDocument.docx"); doc.UpdateFields(); doc.Save(ArtifactsDir + "Field.RD.docx");