Adobe Acrobat Reader cannot open PDF file generated by Aspose.PDF

I’m using this simple code

Aspose.Pdf.HtmlLoadOptions htmlLoadOptions = new Aspose.Pdf.HtmlLoadOptions(ResourcesDirectoryPath);
var document = new Aspose.Pdf.Document(htmlFilePath, htmlLoadOptions);

document.Save(filePath); // .pdf file

Works like a charm everywhere except Acrobat Reader, it cannot open it because file is corrupt.

I also tried do file saving through memory stream:

using (var ms = new MemoryStream())
{	
	document.Save(ms, SaveFormat.Pdf);

	using (FileStream file = new FileStream(filePath, FileMode.Create, FileAccess.Write))
	{
		 ms.Flush();
		 var bytes = ms.ToArray();
		 file.Write(bytes, 0, bytes.Length);
		 file.Close();
		 ms.Close();
	}
}

with the same result.
We are using Aspose.PDF 18.7, but it looks like owners of later versions struggling with the same issue.

Any hint or help would be appreciated.

@SergTomcat

Would you kindly share your sample HTML file with us. We will test the scenario in our environment and address it accordingly.

@asad.ali, of course. Here’s HTML and resulting PDF.

sample.zip (56.2 KB)

Thank you in advance.

@SergTomcat

We tested the scenario in our environment while using Aspose.PDF for .NET 20.4 and were unable to notice any issue with output PDF. It was able to open with Adobe Reader.

HtmlLoadOptions objLoadOptions = new HtmlLoadOptions();
objLoadOptions.PageInfo.Margin = new MarginInfo(0, 0, 0, 0);
objLoadOptions.PageInfo.IsLandscape = true;
Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir + "report64134.html", objLoadOptions);
doc.Save(dataDir + "htmltopdf.pdf");

htmltopdf.pdf (56.1 KB)

Would you kindly try using the latest version of API and in case you still face any issue, please let us know.