Page 1 of 1

Page break in PDF

Posted: Tue Dec 06, 2016 5:08 pm
by SimonH
I have a few topic groups in a chapter that I would like to start on new page as they belong together rather than just flowing from the previous set of topics.

I was hoping I could do it with the following in the XSLT:

<xsl:attribute-set name="topicgroup">
<xsl:attribute name="break-before">page</xsl:attribute>
</xsl:attribute-set>

However, I then noticed this had no effect and discovered the following was commented out so no processing of topicgroup takes place:

<!-- The following three template matches are based on class attributes
that do not exist. They have been commented out starting with
the DITA-OT 1.5 release, with SourceForge tracker #2882085. -->

<!--<xsl:template match="*[contains(@class, ' topic/topicgroup ')]">
<fo:block xsl:use-attribute-sets="topicgroup" id="{@id}">
<xsl:apply-templates/>
</fo:block>
</xsl:template>-->

I tried uncommenting it but with no luck.

Any idea's how to force the PDF to page-break before a <topicgroup> in the bookmap?

Re: Page break in PDF

Posted: Wed Dec 07, 2016 1:45 pm
by radu_pisoi
Hi,

First of all, please note that my response is based on DITA-OT 1.8.5.

Few words about PDF 2 plugin development
Whenever you develop a PDF2 plugin customization, it is useful to explore the temporary files produced by the DITA-OT PDF2 transformation. These files are usually generated in the temp/pdf folder, near the DITA map that you transform and they are deleted by default at the end of the transformation. You can choose to keep them by setting the clean.temp parameter to no.

For your case, it is important to open and explore the structure of the temp/pdf/stage1a.xml temporary file. This file represents the input of the XSLT stylesheet that generates the XSL-FO file, you can see that by analyzing the PDF transformation log.

Code: Select all

transform.topic2fo.main:
[xslt] Processing D:\workspace\eXml\samples\dita\flowers\temp\pdf\stage1a.xml to D:\workspace\eXml\samples\dita\flowers\temp\pdf\stage2.fo
[xslt] Loading stylesheet D:\workspace\eXml\frameworks\dita\DITA-OT\plugins\org.dita.pdf2\xsl\fo\topic2fo_shell_fop.xsl
[xslt] D:\workspace\eXml\frameworks\dita\DITA-OT\plugins\org.dita.pdf2\xsl\fo\front-matter.xsl:82:40: Warning! A variable with no following sibling instructions has no effect
The stage1a.xml file is obtained by merging all the topics from the DITA map after all DITA features was resolved like conditional processing, reusing, etc. It also contains information about the initial DITA map structure.

You can see the structure of this file in the next screenshot:

Image

1. As the first child of the root, you can find an opentopic:map element that reflects/keeps the structure of the input DITA map.

Code: Select all

 <opentopic:map xmlns:opentopic="http://www.idiominc.com/opentopic"
xmlns:ot-placeholder="http://suite-sol.com/namespaces/ot-placeholder">
<topicref class="- map/topicref " first_topic_id="#unique_1" href="#unique_1" id="unique_1"
ohref="topics/introduction.dita" type="topic" xtrc="topicref:1;4:45"
xtrf="D:\workspace\eXml\samples\dita\flowers\flowers.ditamap">
2. The second part of the document, after the opentopic:map element, contains all the topics from your publication together with their content (title, body). It is processed to produce the main part of the PDF document.

Now, the reason why your template has no effect is that the second part of the stage1.xml file has no entry for the topicgroup element.

The good news is that you can interrogate the opentopic:map structure to see if the current processing topic is child of a topicgroup or not.

To make the connection between the current topic and its corresponding topic from the opentopic:map structure you can use the map-id key defined in the next the frameworks/dita/DITA-OT/plugins/org.dita.pdf2/xsl/fo/commons.xsl stylesheet.

So, a solution for your use case is to add the next attribute-set in your customization:

Code: Select all

<xsl:attribute-set 
name="topic"
use-attribute-sets="base-font">
<xsl:attribute name="break-before">
<xsl:choose>
<xsl:when test="key('map-id', @id)[1]/ancestor::topicgroup">page</xsl:when>
<xsl:otherwise>auto</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:attribute-set>

Re: Page break in PDF

Posted: Wed Dec 07, 2016 7:06 pm
by SimonH
I've set the temp folder not to be cleaned so I'm starting to understand more by digging through the files.

I tried the suggested solution but it didn't do anything. I'm trying to debug why not.

Even I set the <xsl:otherwise> statement to page there's still no breaks when it produces the output.

Re: Page break in PDF

Posted: Wed Dec 07, 2016 9:40 pm
by SimonH
Looking at the generated .fo files it appears the "topic" attributes are only applied to the chapter...

Re: Page break in PDF

Posted: Thu Dec 08, 2016 12:18 pm
by radu_pisoi
Hi,

I forgot to say I've tested with a regular DITA map. For a DITA bookmap the temporary file structure and XPath expressions might be little different.

Re: Page break in PDF

Posted: Thu Dec 08, 2016 2:15 pm
by SimonH
I've figured that the property is going to have to go in topic.topic.title for it to work in a bookmap. I'm just struggling to modify the XPath expression to work properly in that context.