Original Html: InputHtml.zip (550.1 KB)
Look please my Html example which I try convert to PDF.
This is my code
protected byte[] ConvertHtmlToPdf(string htmlDocument, string baseUrl)
{
LicenseManager.SetAsposePdfLicense();
MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(htmlDocument));
var options =
new HtmlLoadOptions(baseUrl)
{
PageInfo =
{
Height = PageSize.A4.Height,
Width = PageSize.A4.Width,
Margin =
{
Left = 30,
Right = 30,
Top = 30,
Bottom = 40
}
}
};
Document pdfDocument = new Document(stream, options);
TextStamp textStamp = new TextStamp("")
{
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Bottom,
BottomMargin = 10
};
foreach (Page page in pdfDocument.Pages)
{
textStamp.Value = $"Page {page.Number} of {pdfDocument.Pages.Count}";
page.AddStamp(textStamp);
}
using (var outputStream = new MemoryStream())
{
pdfDocument.Save(outputStream);
return outputStream.ToArray();
}
}
I have very good result with using HiQPDF library. It is absolutely like original Html in brawser.
But with Aspose result is not very good.
Maybe you help me with possible details, maybe I missed something in code.
HiQPdfREsult: HiQPdfResult.png (56.4 KB)
AsposePdfResult: AsposePdfResult.png (77.0 KB)