DefaultFont and FontSubstitutes when not saving

Hi,
I am using Aspose words to massage my rtf byte[] data to get another byte array. I am not saving the data anywhere. I want to replace the Verdana font with Arial. I tried using DefaultFontName and AddFontSubstitutes but they did not work.

Please advise how to used these functions when not using document saving.

Thank you,
Mahita

Hi Mahita,

Thanks for your inquiry. Please use the following code to meet this requirement:

foreach (Run run in doc.GetChildNodes(NodeType.Run, true))
    if (run.Font.Name.Equals("Verdana"))
        run.Font.Name = "Arial";

I hope, this helps.

Best regards,

That worked. Thank you.

I have another question. I am also trying to substitute the font when importing and exporting documents. Aspose site showed me the Font substitution option for RTFImport but I am looking for substitution when I do am RTF export or Xaml Import. Please advise if there is a way to achieve this.

-Mahita

Hi Mahita,

Thanks for your inquiry. Please check below the list of Load Formats Aspose.Words can build its DOM from:
https://reference.aspose.com/words/net/aspose.words/loadformat/

Once the document is loaded in memory, you can use the code from my previous post to change Font. After that you can use Document.Save method to save it to any of the following Save Formats:
https://reference.aspose.com/words/net/aspose.words/saveformat/

I hope, this helps.

Best regards,