Forcing and preventing page breaks in PDF

Here should go questions about transforming XML with XSLT and FOP.
plumblei
Posts: 26
Joined: Mon Feb 18, 2013 5:44 pm

Forcing and preventing page breaks in PDF

Post by plumblei »

We print our DITA topics to PDF and I noticed that sometimes note sections get splitted leaving the note icon alone at the bottom of a page with the note text on the next page. How can I prevent this?
Also is it possible to prevent an (un)ordered list from splitting if it has 5 items or less? In other words, can I set such a condition for page breaks?
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Forcing and preventing page breaks in PDF

Post by sorin_ristache »

Hello,

You will need to customize the DITA-OT plugin that creates the PDF output when a DITA Map PDF transformation is executed. This plugin is located in directory [Oxygen-install-dir]\frameworks\dita\DITA-OT\plugins\org.dita.pdf2. For the second request (avoid splitting a list on different output pages) you will need to set an XSL-FO property like keep-together.within-page="always" in the intermediary XSL-FO file, on the fo:block element corresponding to the list. You can find some examples of setting XSL-FO attributes in the file [Oxygen-14.2-install-dir]\frameworks\dita\DITA-OT\plugins\org.dita.pdf2\cfg\fo\attrs\lists-attr.xsl. In your customization (which will be an XSLT stylesheet actually) it is enough (I think) to add the following inside the FO attribute sets for the ul and ol lists:

Code: Select all

<xsl:attribute name="keep-together.within-page">always</xsl:attribute>
I suppose the first request (keeping the note icon and the note text on the same page) can be implemented in the same way, you will just have to identify where (in the XSLT stylesheets of the PDF plugin) the XSL-FO code of the note is generated. You may find the DITA transformation debugging suggestions from the Oxygen User Manual helpful in identifying that place.

You can find details about customizing the PDF plugin of DITA-OT in the file README.txt located in the directory of the plugin ([Oxygen-install-dir]\frameworks\dita\DITA-OT\plugins\org.dita.pdf2).


Regards,
Sorin
plumblei
Posts: 26
Joined: Mon Feb 18, 2013 5:44 pm

Re: Forcing and preventing page breaks in PDF

Post by plumblei »

Thank you, Sorin!

As for the notes, I added the line that you provided under

Code: Select all

<xsl:attribute-set name="note" use-attribute-sets="common.block">
in common-attr.xsl and that helped.

As for the lists, the solution you suggested means that all lists will be kept together, whereas we want to keep only 5-item (or less) lists together. So is it possible to add this condition: keep a list together if it has X or less items?
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Forcing and preventing page breaks in PDF

Post by sorin_ristache »

Hi,

If you want to have the attribute only on some lists you will have to customize also other XSLT files from the PDF plugin. I don't know exactly what files, maybe the debug suggestions in the User Manual will help you find the code that creates the list and customizing that.


Regards,
Sorin
Post Reply