ArthurHub / ArthurHub/HTML-Renderer
The library ignores position:absolute styling
- Vorherrschende Sprache
- C#
- Sterne
- 1.4k
- Forks
- 550
- Ø Merge
- 14 T. 9 Std.
- Gemergte PRs (30 T.)
- 1
Beschreibung
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:

Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Start with the supplied C# reproduction through PdfGenerator.GeneratePdf and compare the generated PDF with the HTML positions. Trace how the renderer handles position:absolute, top, and left for these paragraphs; done means the four elements retain distinct offsets instead of collapsing into the top-left corner.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- csharp
- Bereich
- tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 38/100