Free Support Forum -

How to make font family to be invariant?


How to conserv the font family of the “FusionChamp” thats mean my fields in the document have Centry gothic 11 as font family and size , but after exporting to word i noticed that the font changed to New Roman 10 how can make it Inchangeable ?

Hi Ahmed,

Thanks for your inquiry. Aspose.Words should preserve the fonts during processing; could you please attach your input and output Word documents along with conversion code here for testing? I will investigate the issue on my side and provide you more information.

Best regards,

Hello ,

Thanks for your help ,

I attached the input document : AM - décision 2013.doc

the output document : AM - décision 2013.doc2013032817165450.docx

I have a function wich Export field , it take a DataTable as input params

private string MailMerge(string templatePath, DataTable dt, string modelName, string siteUrl, string format)
string portNumber = getPortNumber(siteUrl);
siteUrl = siteUrl.Replace(“http://”, string.Empty);
string downloadUrl = siteUrl.Substring(0, siteUrl.IndexOf("/"));

downloadUrl = “http://” + downloadUrl;

string genFileName = modelName + DateTime.Now.ToString(“yyyyMMddHHmmssff”);
string outputFile = @“C:\inetpub\wwwroot\wss\VirtualDirectories” + portNumber + @"\Documents" + genFileName;

Aspose.Words.License license = new Aspose.Words.License();


Document doc = new Document(templatePath);

doc.MailMerge.FieldMergingCallback = new HandleMergeFieldInsertHtml();



string exten = string.Empty;

if (format.EndsWith(“pdf”)||format.Equals(“3”))
exten = “.pdf”;
outputFile += exten;
doc.Save(outputFile, SaveFormat.Pdf);
else if (format.EndsWith(“docx”) || format.Equals(“2”))
exten = “.docx”;
outputFile += exten;
doc.Save(outputFile, SaveFormat.Docx);
exten = “.doc”;
outputFile += exten;
doc.Save(outputFile, SaveFormat.Doc);

return downloadUrl + @"/Documents/" + genFileName + exten;

Hi Ahmed,

Thanks for the additional information. I think, you can use the following code snippet to be able to merge the formatting that is specified inside HTML string with the formatting of MergeField:

Document doc = new Document(@“C:\test\mf.docx”);

DocumentBuilder builder = new DocumentBuilder(doc);<o:p></o:p>

builder.MoveToMergeField(“mf”, false, false);<o:p></o:p>

InsertHtmlWithBuilderFormatting(builder, “plain html string”);<o:p></o:p>

//InsertHtmlWithBuilderFormatting(builder, “formatted html string”);<o:p></o:p>



You can find code for InsertHtmlWithBuilderFormatting function in the attachment. I hope, this helps.

Best regards,