AddLinkToContent

CustomDocumentProperties.AddLinkToContent method

Skapar en ny länkad till innehåll anpassad dokumentegenskap.

public DocumentProperty AddLinkToContent(string name, string linkSource)
ParameterTypBeskrivning
nameStringNamnet på fastigheten.
linkSourceStringKällan till fastigheten.

Returvärde

Det nyskapade egenskapsobjektet ellernull närlinkSource är ogiltig.

Exempel

Visar hur man länkar en anpassad dokumentegenskap till ett bokmärke.

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

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

// Länka en ny anpassad egenskap till ett bokmärke. Värdet på denna fastighet
// kommer att vara innehållet i bokmärket som det refererar till i "LinkSource"-medlemmen.
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");

Se även