AddLinkToContent

CustomDocumentProperties.AddLinkToContent method

Creates a new linked to content custom document property.

public DocumentProperty AddLinkToContent(string name, string linkSource)
Parameter Type Description
name String The name of the property.
linkSource String The source of the property.

Return Value

The newly created property object or null when the linkSource is invalid.

Examples

Shows how to link a custom document property to a bookmark.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.StartBookmark("MyBookmark");
builder.Write("Hello world!");
builder.EndBookmark("MyBookmark");

// Link a new custom property to a bookmark. The value of this property
// will be the contents of the bookmark that it references in the "LinkSource" member.
CustomDocumentProperties customProperties = doc.CustomDocumentProperties;
DocumentProperty customProperty = customProperties.AddLinkToContent("Bookmark", "MyBookmark");

Assert.AreEqual(true, customProperty.IsLinkToContent);
Assert.AreEqual("MyBookmark", customProperty.LinkSource);
Assert.AreEqual("Hello world!", customProperty.Value);

doc.Save(ArtifactsDir + "DocumentProperties.LinkCustomDocumentPropertiesToBookmark.docx");

See Also