Configuring “Link to content” for bookmarks in Word

Hi.

In your Api Cells there is the possibility to link a property to a named cell or range.
https://docs.aspose.com/display/cellsjava/Managing+Document+Properties

In Office Word there is similar functionality where you may link a CustomDocumentProperty to a bookmark.
I’ve searched through your documentation but could not find this functionality in the Words API, does it exist?

Thanks!

@jandersson

Unfortunately, Aspose.Words does not support the requested feature at the moment. However, we have logged this feature request as WORDSNET-19103 in our issue tracking system. You will be notified via this forum thread once this feature is available. We apologize for your inconvenience.

Could you please ZIP and attach your expected output Word document? We will then provide you more information about your query.

@jandersson,

Please upgrade to the latest version of Aspose.Words for .NET i.e. 19.9.

Regarding WORDSNET-19103, it is to update you that we have added following new public method:

public DocumentProperty AddLinkToContent(string name, string linkSource)

We have also added new public properties:

DocumentProperty.LinkSource,
DocumentProperty.IsLinkToContent

The following simple code demonstrates how to configure “Link to content” Custom Property:

Document doc = new Document(@"test.docx");
 
// Retrieve a list of all custom document properties from the file.
CustomDocumentProperties customProperties = doc.CustomDocumentProperties;
 
// Add linked to content property.
DocumentProperty customProperty = customProperties.AddLinkToContent("PropertyName", "BookmarkName");
 
// Also, accessing the custom document property can be performed by using the property name.
customProperty = customProperties["PropertyName"];
 
// Check whether the property is linked to content.
bool isLinkedToContent = customProperty.IsLinkToContent;
 
// Get the source of the property.
string source = customProperty.LinkSource;
 
// Get the value of the property.
string value = customProperty.Value;

Hope, this helps.

Hi,

Thanks for the help. We decided to purchase aspose either way. But this is great news, but I have to ask will this be implemented for the java API too?

@jandersson,

Yes, please try using the following Aspose.Words for Java code:

Document doc = new Document("test.docx");

// Retrieve a list of all custom document properties from the file.
CustomDocumentProperties customProperties = doc.getCustomDocumentProperties();

// Add linked to content property.
DocumentProperty customProperty = customProperties.addLinkToContent("PropertyName", "BookmarkName");

// Also, accessing the custom document property can be performed by using the property name.
customProperty = customProperties.get("PropertyName");

// Check whether the property is linked to content.
boolean isLinkedToContent = customProperty.isLinkToContent();

// Get the source of the property.
String source = customProperty.getLinkSource();

// Get the value of the property.
String value = customProperty.getValue().toString();

The issues you have found earlier (filed as WORDSNET-19103) have been fixed in this Aspose.Words for .NET 19.10 update and this Aspose.Words for Java 19.10 update.