ContentControl Placeholder text is updated when ContentControl value is set programatically

Hello again,

I have discovered an oddity in DocIO. I have created a Word document with InInlineContentcontrols.

When setting the value in a ContentControl programmatically using your demo method 'ReplaceTextInInlineContentcontrol' both the placeholder text and the user entered text in the contentcontrol are changed - and set to the same value.

This code is where the 'magic' happens using DocIO demo code.

inlineContent.ParagraphItems.Clear();
WTextRange textRange = new(inlineContent.Document);
textRange.Text = text;

I have created a small .Net Framework 4.8 VSTO application to see the values of the contentcontrol.PlaceholderText and the contentcontrol.Range.Text parameters on the same contentcontrol (using VSTO). These parameters should have held different values, but after writing to the contentcontrol with DocIO, they are set to the same value.

Another way to see this is by clicking the Design Mode in Word on the developer tab in a document that has ContentControls. See this explanation: https://gregmaxey.com/word_tip_pages/modify_cc_placeholder_text.html how this would work. After using DocIO to set the value of the contentcontrol, the placeholdertext is also changed in Word.

Is there a way in DocIO to only write to the user defined text of a content control, without changing the value of the placeholder text?

Kind regards,

Niels van Strien



7 Replies

LB Lokesh Baskar Syncfusion Team February 16, 2022 06:21 PM UTC

Hi Strien,

Currently, we are checking the query and we will update the further details on 17th February 2022.

Regards, 
Lokesh B 



NV NM van Strien February 17, 2022 02:07 AM UTC

Hello Lokesh,

Thanks for the update. 

I have spent a day looking at the OpenXML SDK for a solution. By chance I stumbled upon this project: https://github.com/tfsbuildextensions/BuildManager

It contains an OpenXML SDK based document processing library, accessing content controls using OpenXML. There is a method here: https://github.com/tfsbuildextensions/BuildManager/blob/master/Manager/TfsBuildManager.WordDocumentGenerator.Library/OpenXmlHelper.cs

line 339 public static void SetContentOfContentControl(SdtElement contentControl, string content) that accesses the correct text part of the ContentControl, although it does not leave the custom placeholder text in tact either. This method blanks the placeholder and sets the correct text part. I believe there is also a method to set the placeholder, but I have not had the time to test that.

Although syncfusion has a proprietary solution with DocIO, it is compatible with the methods in this library.

Perhaps this is useful information wrt this particular query, and therefore I decided to share this with you..

Kind regards,

Niels van Strien






LB Lokesh Baskar Syncfusion Team February 17, 2022 04:25 PM UTC

Hi Strien,

On further investigation, we have found that when we change the content control value using DocIO, the placeholder text is removed after resaved the Word document. We have reproduced the reported issue and
we suspect that it to be a defect. We will validate this issue and share the details on 21st February 2022.


Regards, 
 
Lokesh B  




LB Lokesh Baskar Syncfusion Team February 23, 2022 11:21 AM UTC

Hi Strien,

We have confirmed that the mentioned “Placeholder value for inline content control is not preserved while resaving DOCX format document” is an issue and we have logged a defect report. We will provide the patch for this defect which is estimated to be available on 09th March 2022.  

The status of this bug report can be tracked through the below link: 
 
https://www.syncfusion.com/feedback/32931/placeholder-value-for-inline-content-control-is-not-preserved-while-resaving-docx

Note: Since you have mentioned your product version as 19.4.0.38, we will provide you the patch for this issue in this version. If you are using any other Essential Studio version then kindly let us know the currently installed version, so that we can provide patch in that version based on our SLA policy.

Regards, 
Lokesh B 



NV NM van Strien February 23, 2022 08:04 PM UTC

Hello Lokesh,


Thank you for researching this issue.


I can update to the latest release of DOCIO if that is of any help.


Kind regards,


Niels van Strien



LB Lokesh Baskar Syncfusion Team March 9, 2022 04:52 PM UTC


Advanced approach – use only if you have specific needs and can directly replace existing assemblies for your build environment
Please find the patch assemblies alone from below location:
https://syncfusion.com/Installs/support/patch/19.4.0.38/1007564/F172876/SyncfusionPatch_19.4.0.38_1007564_3092022104522608_F172876.zip

NuGet:
https://syncfusion.com/Installs/support/patch/19.4.0.38/1007564/F172876/SyncfusionNuget_19.4.0.38_1007564_3092022104522608_F172876.zip

Assembly Version: 19.4.0.38
 
Installation Directions:
This patch should replace the files such as “Syncfusion.DocIO.Base.dll” under the following folder.
$system drive: \ Files\Syncfusion\Essential Studio\$Version # \precompiledassemblies\$Version#\4.0
Eg : $system drive:\Program Files\Syncfusion\Essential Studio\ 19.4.0.38 \precompiledassemblies\ 19.4.0.38 \4.0

To automatically run the Assembly Manager, please check the Run assembly manager checkbox option while installing the patch. If this option is unchecked, the patch will replace the assemblies in precompiled assemblies’ folder only. Then, you will have to manually copy and paste them to the preferred location or you will have to run the Syncfusion Assembly Manager application (available from the Syncfusion Dashboard, installed as a shortcut in the Application menu) to re-install assemblies.

Note:
To change how you receive bug fixes, ask your license management portal admin to change your project’s patch delivery mode.
https://www.syncfusion.com/account/license

Disclaimer:
Please note that we have created this patch for version 19.4.0.38 specifically to resolve the issue reported in the forum #172876.

If you have received other patches for the same version for other products, please apply all patches in the order received.

This fix will be included in our 2022 Volume 1 SP release which will be available at mid of May 2022 tentatively.

The status of this bug task can be tracked through the below feedback link:
https://www.syncfusion.com/feedback/32931/placeholder-value-for-inline-content-control-is-not-preserved-while-resaving-docx


Regards,
Lokesh B
 
 


Loader.
Up arrow icon