ArthurHub / ArthurHub/HTML-Renderer

The library ignores position:absolute styling

Aberta
#203 2 comentários 0 reações 0 responsáveis Ver no GitHub
bug
Linguagem predominante
C#
Estrelas
1.4k
Forks
550
Merge médio
14d 9h
PRs com merge (30d)
1

Descrição

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)

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Direção de pesquisa

Comece com a reprodução em C# fornecida por meio de PdfGenerator.GeneratePdf e compare o PDF gerado com as posições no HTML. Rastreie como o renderer trata position:absolute, top e left para esses parágrafos; considera-se concluído quando os quatro elementos mantêm offsets distintos em vez de colapsarem no canto superior esquerdo.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
csharp
Domínio
tooling
Tipo de issue
Bug
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
38/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.