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

Free Support Forum - aspose.com

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:
http://www.aspose.com/docs/display/wordsnet/Aspose.Words.LoadFormat+Enumeration

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:
http://www.aspose.com/docs/display/wordsnet/Aspose.Words.SaveFormat+Enumeration

I hope, this helps.

Best regards,