Products Technologies Demo Docs Blog Support Company

Restoring the Merge Field Default Behavior

The online document editor provides a default merge field behavior including a specific highlight color, a doubled input position and a highlight mode. When loading an Office Open XML (DOCX) document, this behavior can be adjusted programmatically to provide the same look and feel.

Restoring the Merge Field Default Behavior

The online document editor provides a default merge field behavior including a specific highlight color, a doubled input position and a highlight mode. When loading an Office Open XML (DOCX) document, this behavior can be adjusted programmatically to provide the same look and feel.

The following screenshot shows the default behavior of merge fields in the document editor:

Default merge field behavior

After loading an Office Open XML (DOCX) document into the editor, the fields are imported, but the default behavior is different. The user is only able to see that there is a field at the input position by hovering over the field using the mouse or by checking the enabled ribbon bar buttons such as Field Properties:

Default merge field behavior

The reason why this behavior is not restored is that these properties can be adjusted for each field individually and that the MS Word format (DOCX) doesn't provide such a feature. If you store the document in the internal TX Text Control format, those properties are stored and loaded automatically.

To restore this behavior after loading a document, it is possible to use the JavaScript API to loop through all fields in order to set the specific properties:

TXTextControl.applicationFields.forEach(function(field) { 
        field.setHighlightMode(3); 
        field.setDoubledInputPosition(true);
        field.setHighlightColor("rgba(0, 0, 0, 0.235)");
})

After this, the fields are highlighted in the default color and the doubled input position is added:

Default merge field behavior

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

Related Posts

ASP.NETJavaScriptASP.NET Core

MailMerge: Working with Image Placeholders

The MailMerge class is able to merge form fields, merge fields and objects such as barcodes or images. This article shows how to use image placeholders and how to insert them programmatically.


ASP.NETJavaScriptMailMerge

Text Control Error Navigator Launched

We launched the Text Control Error Navigator to search for error numbers returned by TX Text Control exceptions. Errors can filtered by error numbers and the associated modules.


AngularASP.NETJavaScript

New JavaScript API Calls for Typical MailMerge Tasks

This article shows how to use the improved JavaScript API for typical MailMerge tasks such as inserting merge blocks.


ASP.NETJavaScriptASP.NET Core

Add JavaScript to PDFs with TX Text Control in C# .NET: Time-Based Alerts…

In this article, we explore how to enrich PDF documents with JavaScript using TX Text Control in C# .NET. Read on to learn how to create time-based alerts that trigger actions based on specific…


ASP.NETASP.NET CoreDOCX

Use MailMerge in .NET on Linux to Generate Pixel-Perfect PDFs from DOCX…

This article explores how to use the TX Text Control MailMerge feature in .NET applications on Linux to generate pixel-perfect PDFs from DOCX templates. This powerful combination enables…