Search code examples
itextxmlworker

itextsharp xmlworker remove table padding


I'm using the iTextSharp xmlworker to generate a table grid with borders on the cells. When it renders to the PDF the cells all appear to have cell padding or margins. Any idea how to remove the cell padding? I've tried using padding: 0 styles and the old cellpadding="0" table element attribute, but nothing seems to help. Attaching a pic to illustrate what it is doing. Any ideas? Example iTextSharp table


Solution

  • I was looking at the iText xmlworker CSS conformance list and saw a property called border-collapse. I've never used this property. It seems to fix the problem though.

    border-collapse: collapse;
    

    References:
    Conformance List
    CSS border-collapse

    It isn't perfect, but close enough. Adjacent borders don't share the same pixels like HTML does, but I can shim it to exclude certain borders if needed to workaround this.