fopub - Horizontal align table content

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

fopub - Horizontal align table content

canyon
Hello,

in asciidoctor I have a table with the content centered.

[cols="3*^",options="header", options="footer"]
|===
|Name of Column 1
|Name of Column 2
|Name of Column 3

|Cell in column 1, row 1
|Cell in column 2, row 1
|Cell in column 3, row 1

|Cell in column 1, row 2
|Cell in column 2, row 2
|Cell in column 3, row 2

|Footer in column 1
|Footer in column 2
|Footer in column 3
|===

The html output with asciidoctor works fine.
When converting to pdf via fopub though, I don't get the expected result, but instead all content in the table is left aligned.

I've taken a look into the .xml generated with the
-b docbook
 flag and all the Tables entries contain a
align="center"
 attribute.

Afaik fopub uses apache fop under the hood. So I found this link
Does this ultimately mean there's no way to get an in .adoc centered table centered in the pdf output, without manually padding the columns with empty cells in the .fo file?

Thanks in advance!
Reply | Threaded
Open this post in threaded view
|

Re: fopub - Horizontal align table content

Andrew Carver
The problem seems to be located in FOP. I come to that by quick-and-dirty process of elimination.

I know that the standard DocBook XSL stylesheets are not doing it. Here's a typical row they produce from the DocBook <informaltable> your AsciiDoc generates:

        <fo:table-row>
            <fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt"
                padding-bottom="2pt" border-bottom-width="0.5pt" border-bottom-style="solid"
                border-bottom-color="black" border-end-width="0.5pt" border-end-style="solid"
                border-end-color="black" display-align="before" text-align="center">
                <fo:block>
                    <fo:block space-before.optimum="0.08em" space-before.minimum="0em"
                        space-before.maximum="1.2em"
                        axf:font-variant="common-ligatures oldstyle-nums" text-indent="1.8em">Cell
                        in column 1, row 1</fo:block>
                </fo:block>
            </fo:table-cell>
            <fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt"
                padding-bottom="2pt" border-bottom-width="0.5pt" border-bottom-style="solid"
                border-bottom-color="black" border-end-width="0.5pt" border-end-style="solid"
                border-end-color="black" display-align="before" text-align="center">
                <fo:block>
                    <fo:block space-before.optimum="0.08em" space-before.minimum="0em"
                        space-before.maximum="1.2em"
                        axf:font-variant="common-ligatures oldstyle-nums" text-indent="1.8em">Cell
                        in column 2, row 1</fo:block>
                </fo:block>
            </fo:table-cell>
            <fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt"
                padding-bottom="2pt" border-bottom-width="0.5pt" border-bottom-style="solid"
                border-bottom-color="black" display-align="before" text-align="center">
                <fo:block>
                    <fo:block space-before.optimum="0.08em" space-before.minimum="0em"
                        space-before.maximum="1.2em"
                        axf:font-variant="common-ligatures oldstyle-nums" text-indent="1.8em">Cell
                        in column 3, row 1</fo:block>
                </fo:block>
            </fo:table-cell>
        </fo:table-row>
 
(You'll notice that each fo:table-cell has text-align="center".)

Nor can I see anything in fopub's customization of the stylesheets that would make this happen. Here are the only parameter-setttings it has (in fo-pdf.xsl) that affects tables:

  <!--
    Tables
  -->

  <xsl:attribute-set name="table.cell.padding">
    <xsl:attribute name="padding-left">4pt</xsl:attribute>
    <xsl:attribute name="padding-right">4pt</xsl:attribute>
    <xsl:attribute name="padding-top">2pt</xsl:attribute>
    <xsl:attribute name="padding-bottom">2pt</xsl:attribute>
  </xsl:attribute-set>

  <xsl:param name="table.frame.border.thickness">0.3pt</xsl:param>
  <xsl:param name="table.cell.border.thickness">0.15pt</xsl:param>
  <xsl:param name="table.cell.border.color">#5c5c4f</xsl:param>
  <xsl:param name="table.frame.border.color">#5c5c4f</xsl:param>
  <xsl:param name="table.cell.border.right.color">white</xsl:param>
  <xsl:param name="table.cell.border.left.color">white</xsl:param>
  <xsl:param name="table.frame.border.right.color">white</xsl:param>
  <xsl:param name="table.frame.border.left.color">white</xsl:param>

  <xsl:attribute-set name="table.cell.padding">
    <xsl:attribute name="padding-left">4pt</xsl:attribute>
    <xsl:attribute name="padding-right">4pt</xsl:attribute>
    <xsl:attribute name="padding-top">2pt</xsl:attribute>
    <xsl:attribute name="padding-bottom">2pt</xsl:attribute>
  </xsl:attribute-set>

Also:: after generating the FO (not using fopub but using the standard stylesheets as regards tables), I ran that thru Antenna House XSL Formatter 6.6 (Lite version), and the contents of the formatted table's cells were horizontally centered.

So, that leaves FOP as the culprit (seems to me).

Cheers,
Andy

Reply | Threaded
Open this post in threaded view
|

Re: fopub - Horizontal align table content

canyon
Andy,

thanks for the confirmation!
Seems like left aligned tables are something one has to live with then.
Reply | Threaded
Open this post in threaded view
|

Re: fopub - Horizontal align table content

Andrew Carver
Excuse me, I fear I may have misunderstood your problem. Are you talking about the alignment of cell-contents (as I gathered, based on on your description and your AsciiDoc), or about the alignment of the table as a whole?

I responded based on my reading of your problem, and (therefore) without even testing in on fopub itself. But now that I do that test, I can't even see a problem: The table takes up the width of the page, and contents of all of the cells are centered.

So please, could you go into a little more detail on the exact problem? Thanks!

Andy
Reply | Threaded
Open this post in threaded view
|

Re: fopub - Horizontal align table content

canyon
I'm talking about the alignment of cell contents, not the table as a whole on the page.
Sorry, looking at my reply to your first comment on this it is indeed misleading.

Creating a docbook.xml via asciidoctor and from there using fop with fopub's stylesheets leaves me with all the table's content left aligned.

Interesting though, that running fopub gives you centered content. That would mean that fopub does more changes than just providing some additional stylesheets I reckon?

Reply | Threaded
Open this post in threaded view
|

Re: fopub - Horizontal align table content

Andrew Carver
Interesting indeed. Have you checked that your PDF is exhibiting this problem in numerous PDF readers (browsers, Acrobat Reader, ...)?

canyon wrote
I'm talking about the alignment of cell contents, not the table as a whole on the page.
Sorry, looking at my reply to your first comment on this it is indeed misleading.

Creating a docbook.xml via asciidoctor and from there using fop with fopub's stylesheets leaves me with all the table's content left aligned.

Interesting though, that running fopub gives you centered content. That would mean that fopub does more changes than just providing some additional stylesheets I reckon?