I have HTML code with many elements with style position: absolute. The HTML code looks good in the browser but when I try to convert it to pdf using HtmlRenderer.PdfSharp, I get all the elements in the top left corner. How can I fix this?
Here is my code:
usingPdfSharp;usingPdfSharp.Pdf;usingTheArtOfDev.HtmlRenderer.PdfSharp;varhtml="...";File.WriteAllBytes("draft.html",Encoding.UTF8.GetBytes(html));usingPdfDocumentpdf=PdfGenerator.GeneratePdf(html,PageSize.A4,margin:0);usingvarms=newMemoryStream();pdf.Save(ms);File.WriteAllBytes("draft.pdf",ms.ToArray());returnms.ToArray();The html:
<!DOCTYPE html><html><head><metahttp-equiv="Content-Type" content="text/html; charset=UTF-8"/></head><body><pstyle="position: absolute; top: 50px; left: 200px;margin: 0;">Hello world!</p><pstyle="position: absolute; top: 100px; left: 200px;margin: 0;">Hello world!1</p><pstyle="position: absolute; top: 150px; left: 200px;margin: 0;">Hello world!2</p><pstyle="position: absolute; top: 200px; left: 200px;margin: 0;">Hello world!3</p></body></html>
Below is how the generated pdf looks like:

I have HTML code with many elements with style position: absolute. The HTML code looks good in the browser but when I try to convert it to pdf using HtmlRenderer.PdfSharp, I get all the elements in the top left corner. How can I fix this?
Here is my code:
The html:
Below is how the generated pdf looks like:
