Issue while generating pdf using Aspose.Word

Hi,

We are using license version of ASPOSE. Currently we are
facing issue while generating pdf for set of documents. Here we are generating one
pdf doc from all the documents attached. Following is code we are using to
convert doc to pdf.

 foreach (string item in doclist)
{
    HtmlDocument htmlDoc = new HtmlDocument();
    htmlDoc.LoadHtml(item);

    htmlDoc = ReplaceImageSrcWithSAS(htmlDoc);
    StringBuilder sb = new StringBuilder(htmlDoc.DocumentNode.InnerHtml);

    sb = sb.Replace("<html>", "");
    sb = sb.Replace("</html>", "");

    sb = sb.Replace("<body>", "");
    sb = sb.Replace("</body>", "");

    sb = sb.Replace("<head>", "");
    sb = sb.Replace("</head>", "");
    header = header + "<BR><HR><BR>" + sb.ToString();
}

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


string LicenseFilePath = Server.MapPath("~/") + @"Content\Aspose.Total.lic";
license.SetLicense(LicenseFilePath);

// Retrieve the array of environment-dependent font sources that are searched by default. For example this will contain a "Windows\Fonts\" source on a Windows machines.
// We add this array to a new ArrayList to make adding or removing font entries much easier.
ArrayList fontSources = new ArrayList(FontSettings.GetFontsSources());

// Add a new folder source which will instruct Aspose.Words to search the following folder for fonts. 

FolderFontSource folderFontSource = new FolderFontSource(Server.MapPath("~/") + @"redistributables\editlivejava\css", true);

// Add the custom folder which contains our fonts to the list of existing font sources.
fontSources.Add(folderFontSource);

// Convert the Arraylist of source back into a primitive array of FontSource objects.
FontSourceBase[] updatedFontSources = (FontSourceBase[])fontSources.ToArray(typeof(FontSourceBase));


// Apply the new set of font sources to use.
FontSettings.SetFontsSources(updatedFontSources);

Stream htmlStream = new MemoryStream(Encoding.UTF8.GetBytes(header));


Aspose.Words.Document doc = new Aspose.Words.Document(htmlStream, new LoadOptions()
{
    LoadFormat = LoadFormat.Html,
    ResourceLoadingCallback = new AsposeResourceLoadingHandler()
});

htmlStream.Close();

doc.Save(outputStream, SaveOptions.CreateSaveOptions(SaveFormat.Pdf));

We used Aspose.word version 11.7.0.0. Please note listed
issue is reproduced occasionally on production environment. However same
document set is working fine when run on local environment.

Below are the stack trace of the exception we faced

Aspose.Words.UnsupportedFileFormatException: Unknown file
format.
   at
Aspose.Words.Document.x5d4db34d48fb3129(Stream xcf18e5243f8d5fd3, LoadOptions
x27aceb70372bde46)
   at
Aspose.Words.Document.x5d95f5f98c940295(Stream xcf18e5243f8d5fd3, LoadOptions
x27aceb70372bde46)<br>Thanks You.

Hi Sandeep,

Thanks for your inquiry. Could you please attach your input documents here for testing? I will investigate the issue on my side and provide you more information.