ArthurHub / ArthurHub/HTML-Renderer

The library ignores position:absolute styling

未关闭
#203 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
bug
主要语言
C#
星标
1.4k
派生
550
平均合并
14 天 9 小时
30 天内合并 PR
1

描述

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:
```c#
using PdfSharp;
using PdfSharp.Pdf;
using TheArtOfDev.HtmlRenderer.PdfSharp;

var html = "...";
File.WriteAllBytes("draft.html", Encoding.UTF8.GetBytes(html));
using PdfDocument pdf = PdfGenerator.GeneratePdf(html, PageSize.A4, margin:0);
using var ms = new MemoryStream();
pdf.Save(ms);
File.WriteAllBytes("draft.pdf", ms.ToArray());
return ms.ToArray();
```
The html:
```html

Hello world!


Hello world!1


Hello world!2


Hello world!3

```
Below is how the generated pdf looks like:
![MPt2s](https://github.com/ArthurHub/HTML-Renderer/assets/39989294/2ac154ef-9584-442e-8897-9ef8d9f1d7ed)

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。