Replace text in Microsoft Word Document in .NET changes the font size using Aspose.Words API

Hello Aspose Support

I’m having an issue using Aspose Word causing the change in Font size when a text is replaced in the word document and saved in a new file. I compare the document.xml extracted from the word document and see an extra tag

<w:sz w:val=“16” />

is added by the Aspose, this is causing the font size of 8 appering the new replaced document.

May you please suggest the cause of this behavious.

Is this is a bug in Aspose library or can it be avoided using the certain feature of Aspose

Product - Aspose.Words for .NET
Version - 2016.05.31

Method to replace the text -

public ReplaceText(Aspose.Words.Document report, string oldValue, string newValue, string newDocPath)
{
	foreach (Section section in report.Sections)
	{
		foreach (Paragraph paragraph in section.Body.GetChildNodes(NodeType.Paragraph, true))
		{
			foreach (Run run in paragraph.Runs)
			{
				run.Text = run.Text.Replace(oldValue, newValue);
			}
		}
	}
	report.Save(newDocPath, SaveFormat.Docx);
}

Document.xml Before Text Replacement -

<w:r>
  <w:rPr>
    <w:lang w:val="en-US" />
  </w:rPr>
  <w:t>${Board.GetCcy1()}$</w:t>
</w:r>

Document.xml Before Text Replacement -

<w:r>
  <w:rPr>
    <w:sz w:val="16" />
    <w:lang w:val="en-US" />
  </w:rPr>
  <w:t>USD</w:t>
</w:r>

@nagendran.venkat.uni,

Thanks for your inquiry. We have already answered your query here in this post. Please follow that thread for further proceedings.

Moved to: Font Size of 8 is set by Aspose on Text Replace - Free Support Forum - aspose.com