Quantcast
Channel: HTML Renderer
Viewing all articles
Browse latest Browse all 693

Commented Unassigned: PDF generation fails for tables with span element [9064]

$
0
0
This is an example of table which contains span element inside cell. Function TheArtOfDev.HtmlRenderer.PdfSharp.PdfGenerator.GeneratePdf generates just blank page. In some cases, Adobe Reader even reports that PDF is invalid. Without span it works fine. Due to this bug it's impossible to render Word generated tables to PDF.

```
<table>
<tr><td><span>123</span></td></tr>
</table>
```

Fails also for font and maybe for some other tags.
```
<table>
<tr><td><font>123</font></td></tr>
</table>
```

PS. - Thanks for this great library and keep up that good work!
Comments: Hi, I stumbled across a very similar issue. Even with the home html in the WinForms Demo project the second page of the generated PDF is empty and Adboe reader (tested 10 and 11) occasionally reports an error. Other PDF viewers like gsview or Foxit reader are able to open the document. After analyzing the generated PDF and playing with the renderer source code I found that Adobe reader doesn't like it when a clip path is being set without actually defining a path first. In the PDF file it looks like this (from decoded page content stream): ``` q //push stack W* n //set current path as clip path Q //pop stack ``` I was able to fix it by avoiding to clip to an empty recangle in HtmlRenderer.PdfSharp.Adapters.GraphicsAdapter.PushClip() and HtmlRenderer.PdfSharp.Adapters.GraphicsAdapter.PopClip(): ``` public override void PopClip() { RRect rect = _clipStack.Pop(); if (!rect.IsEmpty) { _g.Restore(); } } public override void PushClip(RRect rect) { _clipStack.Push(rect); if (!rect.IsEmpty) { _g.Save(); _g.IntersectClip(Utils.Convert(rect)); } } ``` Complete changed file is attached. Best regards Lars

Viewing all articles
Browse latest Browse all 693

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>