We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problem while replacing the placeholder with value

Hi Team,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

We are having an issue with the placeholder value replacement in the word template in one of our application.

Users configures placeholder on the word template i.e. [%PlaceHolder%] and application uses Aspose word library (version 10.0.7.0) to replace placeholder with the value.

It works fine for all the placeholders (starts with “ [% ” then text and end with “ %] ” ) but some placeholders were not getting replaced while processing.

Root cause:

After analysis we found issue occurs for some format sequence inserted by MS Word at background of the template whilst creating placeholder.

For example: Below text was created in background for [%Private Address Line 1%]

Please see the attachment 1.

While correct one would be:

please see the attachment 2.

Current Implementation:

We are using Aspose word (version 10.0.7.0) for word processing. We have a scenario in which we are replacing placeholders (for ex. [%ABC%]) with some values using replacing method (public override ReplaceAction Replacing(ReplacingArgs args)) of IReplacingCallback interface.

Code:

public override ReplaceAction Replacing(ReplacingArgs args)

{

return ReplaceWith(args, (builder) =>

{

if (TextColor != Color.Empty)

builder.Font.Color = TextColor;

builder.Write(ReplacementText);

});

}

Now a question is:

Is there any way to resolve above issue using Aspose word version 10.0.7.0.?

Or we need to upgrade it to latest version of aspose .

Hi Ratnesh,


Thanks for your inquiry. It would be great if you please share following details for testing purposes. I will investigate the issue on my side and provide you more information.

  • Please create a simple application (for example a Console Application Project) that helps us reproduce the same problem on our end and attach it here for testing.
  • Please supply us with the input document that is causing the issue
  • Please supply us with the output document showing the undesired behavior
  • Please supply us with the expected document showing the desired behavior (You can create this document using Microsoft Word).