How to keep all entire rows together on the same page when assembling tables.

Here should go questions about transforming XML with XSLT and FOP.
shiney_98
Posts: 7
Joined: Thu Sep 09, 2021 12:03 pm

How to keep all entire rows together on the same page when assembling tables.

Post by shiney_98 » Thu Sep 09, 2021 12:08 pm

How to avoid page-break in rows of the table
Last edited by shiney_98 on Tue Sep 14, 2021 2:20 pm, edited 1 time in total.

julien_lacour
Posts: 210
Joined: Wed Oct 16, 2019 3:47 pm

Re: How to keep all entire rows together on the same page when assembling tables.

Post by julien_lacour » Thu Sep 09, 2021 1:47 pm

Hello,

Yes, the keep-together.within-page FO attribute will help you avoiding page-breaks inside a row.

If you are using DITA documents and the DITA Map PDF - based on XSL-FO transformation on a recent version of Oxygen (which uses DITA-OT 3.x), the following style-sheet is included by default:

Code: Select all

<xsl:attribute-set name="tbody.row">
  <!--Table body row-->
  <xsl:attribute name="keep-together.within-page">always</xsl:attribute>
</xsl:attribute-set>
Which means that all the <fo:table-row> elements present the attribute, like this:

Code: Select all

<fo:table-row keep-together.within-page="always">
    ...
</fo:table-row>
Could you indicate which version of Oxygen you are currently using?
Could you also precise which input you want to transform into PDF?

Regards,
Julien

shiney_98
Posts: 7
Joined: Thu Sep 09, 2021 12:03 pm

Re: How to keep all entire rows together on the same page when assembling tables.

Post by shiney_98 » Mon Sep 13, 2021 6:55 am

Hi, thanks for the reply.

Could you indicate which version of Oxygen you are currently using?
The current version I'm using is Oxygen 23.0

Could you also precise which input you want to transform into PDF?
While assembling tables in a dita document file(topic), I want the table rows with content that could bleed into another page to stay on one page while transforming to PDF.

shiney_98
Posts: 7
Joined: Thu Sep 09, 2021 12:03 pm

Re: How to keep all entire rows together on the same page when assembling tables.

Post by shiney_98 » Mon Sep 13, 2021 11:53 am

I wanted to keep the contents of the row together on the same page while assembling tables.. I've tried using keep-together.within-page="always", keep-together.within-column="always" and keep-with-next.within.page="always" separately in <fo:table-row> but it is not showing the desired result. What should be done in-order to get the content of row together on the same page?
Last edited by shiney_98 on Thu Sep 16, 2021 9:38 am, edited 2 times in total.

julien_lacour
Posts: 210
Joined: Wed Oct 16, 2019 3:47 pm

Re: How to keep all entire rows together on the same page when assembling tables.

Post by julien_lacour » Fri Sep 17, 2021 9:58 am

Hello,

As I mentioned before, in the DITA Map PDF - based on XSL-FO transformation, this attribute is automatically set by the following attribute-set (in org.dita.pdf2/cfg/fo/attrs/tables-attr.xsl):

Code: Select all

<xsl:attribute-set name="tbody.row">
  <!--Table body row-->
  <xsl:attribute name="keep-together.within-page">always</xsl:attribute>
</xsl:attribute-set>
If you run the default transformation you will see that the table row is moved into another page, like in this example:
table.png
table.png (43.62 KiB) Viewed 214 times
Rows from table body are generated by the following template:

Code: Select all

<xsl:template match="*[contains(@class, ' topic/tbody ')]/*[contains(@class, ' topic/row ')]">
    <fo:table-row xsl:use-attribute-sets="tbody.row">
        <xsl:call-template name="commonattributes"/>
        <xsl:apply-templates/>
    </fo:table-row>
</xsl:template>
You can use this template as a starting point for your customization.

You can also run the transformation with the clean.temp=no parameter, you can then check the topic.fo file.
It must contain <fo:table-row keep-together.within-page="always"> for each table row.

Regards,
Julien

shiney_98
Posts: 7
Joined: Thu Sep 09, 2021 12:03 pm

Re: How to keep all entire rows together on the same page when assembling tables.

Post by shiney_98 » Fri Sep 17, 2021 10:17 am

Thanks a lot.

Post Reply