How to force a page break after each first level topic

Having trouble installing Oxygen? Got a bug to report? Post it all here.
BogdanM777
Posts: 68
Joined: Tue Jun 09, 2015 6:26 pm
Location: Canada

How to force a page break after each first level topic

Post by BogdanM777 »

Hi guys,

I was wondering if there is a solution to inserting a page break after each level 1 topics.
I found an older reply to this issue at:

topic3261.html

However the file mentioned there is not to be found in DITA OT anymore.
Is there any other file where I have to do a similar change to get a page break after each level 1 topics?

Thank you
bogdan_cercelaru
Posts: 222
Joined: Tue Jul 01, 2014 11:48 am

Re: How to force a page break after each first level topic

Post by bogdan_cercelaru »

Hello,

The following procedure explains how to customize the PDF output by setting up a customization directory.
  1. Copy the entire directory: DITA_OT_DIR\plugins\org.dita.pdf2\Customization to another location (for instance, C:\Customization).
  2. Rename C:\Customization\catalog.xml.orig to: C:\Customization\catalog.xml.
  3. Open the catalog.xml in Oxygen XML Editor and uncomment this line:

    Code: Select all

    <!--uri name="cfg:fo/attrs/custom.xsl" uri="fo/attrs/custom.xsl"/-->
    So now it looks like this:

    Code: Select all

    <uri name="cfg:fo/attrs/custom.xsl" uri="fo/attrs/custom.xsl"/>
  4. Rename the file: C:\Customization\fo\attrs\custom.xsl.orig to: C:\Customization\fo\attrs\custom.xsl
  5. Open the custom.xsl file in Oxygen XML Editor and add the "attribute-set" that you want to customize(in your case: "topic.topic.title"). Now, custom.xsl has the following content:

    Code: Select all

    <xsl:attribute-set name="topic.topic.title">
    <xsl:attribute name="break-before">page</xsl:attribute>
    </xsl:attribute-set>
  6. Edit the DITA Map to PDF transformation scenario and in the Parameters tab, set the customization.dir parameter to C:\Customization.
You can find more information regarding PDF customization in our user-guide: Customizing DITA Transformations / DITA to PDF Output Customization / Creating a Customization Directory for PDF Output

Regards,
Bogdan
Bogdan Cercelaru
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
BogdanM777
Posts: 68
Joined: Tue Jun 09, 2015 6:26 pm
Location: Canada

Re: How to force a page break after each first level topic

Post by BogdanM777 »

Thank you so much Bogdan.
I will try it right away and let you know how it goes, OK?
BogdanM777
Posts: 68
Joined: Tue Jun 09, 2015 6:26 pm
Location: Canada

Re: How to force a page break after each first level topic

Post by BogdanM777 »

Hi Bogdan,

I did what you suggested, and it worked nicely, however now I have an empty page after each chapter.
Is there a possibility to remove that please?

Thank you
BogdanM777
Posts: 68
Joined: Tue Jun 09, 2015 6:26 pm
Location: Canada

Re: How to force a page break after each first level topic

Post by BogdanM777 »

I forgot to say that now also all the entries of the Glossary are each on a new page, and this is a little bit annoying.
I have the glossary as a chapter with the reference to the glossary.ditamap

Thank you
bogdan_cercelaru
Posts: 222
Joined: Tue Jul 01, 2014 11:48 am

Re: How to force a page break after each first level topic

Post by bogdan_cercelaru »

Hello,

I'm afraid I don't have a solution for this. If you add a page break this way, it also adds the page for glossary since it is also considered a first level topic.

I would recommend to also register and ask this on the DITA users group discussion list:
https://groups.yahoo.com/neo/groups/dita-users/info
or the DITA-OT users group:
https://groups.google.com/forum/#!forum/dita-ot-users

Regards,
Bogdan
Bogdan Cercelaru
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
dgallo
Posts: 90
Joined: Tue Mar 31, 2015 10:43 pm

Re: How to force a page break after each first level topic

Post by dgallo »

Hello,

This customization works, but it only breaks topics that are nested two topics deep.

<xsl:attribute-set name="topic.topic.title">
<xsl:attribute name="break-before">page</xsl:attribute>
</xsl:attribute-set>


Is there a way to tell it to break before every topic?

Example:

Topic 1
Topic 2
Topic 3
Topic 4
Topic 5
....

I want every topic to start on a new page, and break after the previous page.
Radu
Posts: 9049
Joined: Fri Jul 09, 2004 5:18 pm

Re: How to force a page break after each first level topic

Post by Radu »

Hi,

In the XSLT stylesheet:

DITA-OT/plugins/org.dita.pdf2/cfg/fo/attrs/commons-attr.xsl

are all the attribute sets used to output a topic's title like "topic.title" (for first level topics), "topic.topic.title" for second level topics, "topic.topic.topic.title" for third level topics.
So one option would be for you to override in your customization as many such nested topic title attribute set names as possible and add the break-before attribute.

Another possibility would be to look in the XSLT:

DITA-OT/plugins/org.dita.pdf2/xsl/fo/commons.xsl

at the template which processes a topic's title:

Code: Select all

    <xsl:template match="*" mode="processTopicTitle">
override it entirely in your customization and add that page break attribute on the fo:block element.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Edwin
Posts: 22
Joined: Tue May 17, 2016 4:58 pm

Re: How to force a page break after each first level topic

Post by Edwin »

bogdan_cercelaru wrote:Hello,

The following procedure explains how to customize the PDF output by setting up a customization directory.
  1. Copy the entire directory: DITA_OT_DIR\plugins\org.dita.pdf2\Customization to another location (for instance, C:\Customization).
  2. Rename C:\Customization\catalog.xml.orig to: C:\Customization\catalog.xml.
  3. Open the catalog.xml in Oxygen XML Editor and uncomment this line:

    Code: Select all

    <!--uri name="cfg:fo/attrs/custom.xsl" uri="fo/attrs/custom.xsl"/-->
    So now it looks like this:

    Code: Select all

    <uri name="cfg:fo/attrs/custom.xsl" uri="fo/attrs/custom.xsl"/>
  4. Rename the file: C:\Customization\fo\attrs\custom.xsl.orig to: C:\Customization\fo\attrs\custom.xsl
  5. Open the custom.xsl file in Oxygen XML Editor and add the "attribute-set" that you want to customize(in your case: "topic.topic.title"). Now, custom.xsl has the following content:

    Code: Select all

    <xsl:attribute-set name="topic.topic.title">
    <xsl:attribute name="break-before">page</xsl:attribute>
    </xsl:attribute-set>
  6. Edit the DITA Map to PDF transformation scenario and in the Parameters tab, set the customization.dir parameter to C:\Customization.
You can find more information regarding PDF customization in our user-guide: Customizing DITA Transformations / DITA to PDF Output Customization / Creating a Customization Directory for PDF Output

Regards,
Bogdan
Hi when I use this procedure in Oxygen v18 I get the following exception:

Code: Select all

C:\Program Files\Oxygen XML Editor 18\frameworks\dita\DITA-OT2.x\build.xml:41: The following error occurred while executing this line:
C:\Program Files\Oxygen XML Editor 18\frameworks\dita\DITA-OT2.x\plugins\org.dita.base\build_preprocess.xml:226: java.lang.NullPointerException
Can anybody comment what's the case?

Hi I've found out the problem you need to add the pagebreak at the top level topic.title

Code: Select all

<xsl:attribute-set name="topic.title" use-attribute-sets="common.title">
<xsl:attribute name="break-before">page</xsl:attribute>
</xsl:attribute-set>
Last edited by Edwin on Wed May 25, 2016 11:46 am, edited 1 time in total.
Radu
Posts: 9049
Joined: Fri Jul 09, 2004 5:18 pm

Re: How to force a page break after each first level topic

Post by Radu »

Hi,

Could you double check that the received error is related to your customization?
For example if you publish without your customization folder, does the publishing work?

You seem to be using DITA Open Toolkit 2.x for publishing. In the Oxygen Preferences->DITA page you can configure the default used DITA Open Toolkit. For Oxygen 17.1 and older the used DITA OT was 1.8 so possibly this problem you encountered is a bug in DITA Open Toolkit 2.x. Could you paste in a code block the entire output received from the DITA OT ANT console? Or attach that to an email if you prefer...

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply