Search code examples
pdfpdf-generationxsl-foapache-fop

Table "disappers" during XSL-FO to PDF conversion


I have the following mark-up for a table at the beginning of larger XSL-FO file:

<fo:table-and-caption xmlns:fo="http://www.w3.org/1999/XSL/Format" display-align="center">
    <fo:table border="1px" border-collapse="separate" border-color="#000000" border-spacing="2px" border-style="outset" border-width="1px" role="table" text-align="center">
        <fo:table-body end-indent="0pt" last-line-end-indent="0pt" role="tbody" start-indent="0pt" text-align="start" text-align-last="relative" text-indent="0pt">
            <fo:table-row role="tr">
                <fo:table-cell border="1px" border-style="inset" padding="1px" role="td">
                    <fo:block>
                        <fo:inline font-family="comic sans ms,sans-serif" font-size="medium" role="span">Top Left</fo:inline>
                    </fo:block>
                </fo:table-cell>
                <fo:table-cell border="1px" border-style="inset" padding="1px" role="td">
                    <fo:block>
                        <fo:inline font-family="comic sans ms,sans-serif" font-size="medium" role="span">Top Right</fo:inline>
                    </fo:block>
                </fo:table-cell>
            </fo:table-row>
            <fo:table-row role="tr">
                <fo:table-cell border="1px" border-style="inset" padding="1px" role="td">
                    <fo:block>
                        <fo:inline font-family="comic sans ms,sans-serif" font-size="medium" role="span">Bottom Left</fo:inline>
                    </fo:block>
                </fo:table-cell>
                <fo:table-cell border="1px" border-style="inset" padding="1px" role="td">
                    <fo:block>
                        <fo:inline font-family="comic sans ms,sans-serif" font-size="medium" role="span">Bottom Right</fo:inline>
                    </fo:block>
                </fo:table-cell>
            </fo:table-row>
        </fo:table-body>
    </fo:table>
</fo:table-and-caption>

The overall setup is described in my PDF report with embedded HTML question.

When our application transforms it to PDF using Apache POF, the table "disappears". The rest of the file seems to be normally converted.

Is there anything wrong with the above code?


Solution

  • See http://xmlgraphics.apache.org/fop/compliance.html. fo:table-and-caption is not supported. That may be the cause of your problem.

    Since you don't have a caption, and since it's not supported by FOP anyway, why not omit the fo:table-and-caption element?