Hai,
I was trying to convert a docx file to html pages, when I am trying to convert each page of docx to seperate html files, html page is generatimg addtional pages at certain pages
@pooja.jayan The problem might be caused by font substitution. While conversion your document the following fonts are not available on my side:
MathJax_Math
MathJax_Main
MathJax_AMS
MathJax_Size2
MathJax_Size3
MathJax_Size4
MathJax_Size1
Could you please attach these fonts here for testing? We will check the issue and provide you more information.
Also, you can check whether the fonts are available on your side by Implementing IwarningCallback like in the following example:
Document doc = new Document(@"C:\Temp\in.docx");
doc.WarningCallback = new WarningCallback();
doc.Save(@"C:\Temp\out.pdf");
private class WarningCallback : IWarningCallback
{
public void Warning(WarningInfo info)
{
if (info.WarningType == WarningType.FontSubstitution)
Console.WriteLine(info.Description);
}
}
@pooja.jayan Could you please also convert your document to PDF and XPS using Aspose.Words and MS Word on your side? I will compare the results and provide you more information.
If the fonts are not available Aspose.Words applied a set of substitution rules. You can configure these rules to get more accurate result.
@pooja.jayan Thank you for additional information. As I can see in your code you are using Document.ExtractPages method. It is not required to use this method if your target format is fixed page format, like PDF, XPS or FixedHtml. Please modify your code like the following:
int pageCount = docFile.PageCount;
for (int page = 0; page < pageCount; page++)
{
using (MemoryStream pageStream = new MemoryStream())
{
// Save each page as a separate document.
HtmlFixedSaveOptions htmlFixedSaveOptions = new HtmlFixedSaveOptions();
htmlFixedSaveOptions.PageSet = new PageSet(page);
htmlFixedSaveOptions.ExportEmbeddedCss = true;
htmlFixedSaveOptions.ExportEmbeddedFonts = true;
htmlFixedSaveOptions.ExportEmbeddedImages = true;
htmlFixedSaveOptions.ExportEmbeddedSvg = true;
htmlFixedSaveOptions.ExportFormFields = true;
htmlFixedSaveOptions.ExportGeneratorName = true;
string cssprefix = "aspose_doc" + page;
htmlFixedSaveOptions.CssClassNamesPrefix = cssprefix;
htmlFixedSaveOptions.AllowEmbeddingPostScriptFonts = true;
//htmlFixedSaveOptions.UseTargetMachineFonts = true;
htmlFixedSaveOptions.SaveFormat = Aspose.Words.SaveFormat.HtmlFixed;
docFile.Save(Path.Combine(path, "convertedHtml", $"{ page + 1}.html"), htmlFixedSaveOptions);
}
}