Loading ...
Sorry, an error occurred while loading the content.

Re: [dita-users] Adding page breaks to PDF

Expand Messages
  • Vic Mortelmans
    Hi, I ve added extra page breaks to my PDF s in DITA-OT1.5.1, by adding this template override in demo/fo/Customization/fo/xsl/custom.xsl. This customization
    Message 1 of 12 , Feb 22, 2013
    • 0 Attachment
      Hi,

      I've added extra page breaks to my PDF's in DITA-OT1.5.1, by adding this template override in demo/fo/Customization/fo/xsl/custom.xsl. This customization has some extra logic: it will only add breaks before sections on level 2 and 3, and not add a break for topics that have no siblings. The code that I've added is in red.

      Regards,
      Vic


        <!-- override of processTopicTitle mode template in demo/fo/xsl/fo/commons.xsl
             to add page breaks for topics on levels 2 and 3, unless the topic has no siblings -->
        <xsl:template match="*" mode="processTopicTitle">
                <xsl:variable name="level" select="count(ancestor::*[contains(@class,' topic/topic ')])"/>
                <xsl:variable name="attrSet1">
                        <xsl:call-template name="createTopicAttrsName">
                                <xsl:with-param name="theCounter" select="$level"/>
                        </xsl:call-template>
                </xsl:variable>
                <xsl:variable name="attrSet2" select="concat($attrSet1, '__content')"/>
                <fo:block id="{@id}">
                        <xsl:call-template name="processAttrSetReflection">
                                <xsl:with-param name="attrSet" select="$attrSet1"/>
                                <xsl:with-param name="path" select="'../../cfg/fo/attrs/commons-attr.xsl'"/>
                        </xsl:call-template>
                        <xsl:if test="$level &gt; 1 and $level &lt; 4 and (count(../preceding-sibling::*[contains(@class,' topic/topic ')]) + count(../following-sibling::*[contains(@class,' topic/topic ')])) &gt; 0">
                          <!-- page break for topics on levels 2 and 3, unless the topic has no siblings
                               note; this template matches the title element -->
                          <xsl:attribute name="break-before">page</xsl:attribute>
                        </xsl:if>
                        <fo:block>
                                <xsl:call-template name="processAttrSetReflection">
                                        <xsl:with-param name="attrSet" select="$attrSet2"/>
                                        <xsl:with-param name="path" select="'../../cfg/fo/attrs/commons-attr.xsl'"/>
                                </xsl:call-template>
                                <xsl:if test="$level = 1">
                                        <fo:marker marker-class-name="current-header">
                                                <xsl:call-template name="getTitle"/>
                                        </fo:marker>
                                </xsl:if>
                                <xsl:if test="$level = 2">
                                        <fo:marker marker-class-name="current-h2">
                                                <xsl:call-template name="getTitle"/>
                                        </fo:marker>
                                </xsl:if>
                                <fo:inline id="{parent::node()/@id}"/>
                                <fo:inline id="{concat('_OPENTOPIC_TOC_PROCESSING_', generate-id(..))}"/><!-- added by William on 2009-07-02 for indexterm bug:2815485 start-->
                                <xsl:call-template name="pullPrologIndexTerms"/><!-- added by William on 2009-07-02 for indexterm bug:2815485 end-->
                                <xsl:call-template name="getTitle"/>
                        </fo:block>
                </fo:block>
        </xsl:template>


      2013/2/21 nosliwennaed <nosliwennaed@...>
       

      Hi all,
      I'm generating a couple of PDFs for a specific project and would like to know if there is a way to insert page breaks before topic titles to format the look and feel of my final documents so that they flow better (and the customer requested it).

      I've looked in Eliot's book for guidance, but didn't find anything specific to page breaks. So, I went straight to the commons-attr.xsl file (in my plugins folder) to see if I could figure it out on my own. I'm still a newbie with xsl, so no joy.

      The second part of the question is: if there is a way to add page breaks, is it all or nothing? That is, would there be a page break before every topic title, or could I specify that page breaks only occur before concept topics, or reference topics, or whatever.

      Oh, I'm using oXygen Author v13.2 to author my content, and DITA-OT 1.5.4 to generate output.

      Thanks,
      Deanne




      --
      Vic Mortelmans
      Klappeistraat 34A - 2060 ANTWERPEN
      03 297 40 23 - 0499 71 06 37

    • matt_kaatman
      I wanted to report that this works great in 1.5.4. If anyone else tries it, make sure you re setting break-before on the topicref and not the topic itself. I
      Message 2 of 12 , Feb 22, 2013
      • 0 Attachment
        I wanted to report that this works great in 1.5.4.

        If anyone else tries it, make sure you're setting break-before on the topicref and not the topic itself. I wasn't paying attention at first and missed that.

        Thanks for sharing!
        Matt

        --- In dita-users@yahoogroups.com, "sus_muris" <sus_muris@...> wrote:
        >
        >
        >
        > Hmm - last week, the editor behaved differently ...
        >
        > <xsl:attribute-set name="topic.topic.topic.title" use-attribute-sets="common.titles">
        > <xsl:attribute name="font-size">16pt</xsl:attribute>
        > </xsl:attribute-set>
        >
        > <xsl:attribute-set name="common.titles">
        > ...
        > <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
        > <xsl:attribute name="break-before">
        > <xsl:variable name="topicref_id" select="parent::*[contains(@class, ' topic/topic ')]/@id"/>
        > <xsl:variable name="topicref_break" select="ancestor::*[contains(@class, ' map/map ')]/*[1]//*[contains(@class,' map/topicref ')][@id=$topicref_id]/@base"/>
        > <xsl:choose>
        > <xsl:when test="$topicref_break='break-before'">page</xsl:when>
        > <xsl:otherwise>auto</xsl:otherwise>
        > </xsl:choose>
        > </xsl:attribute>
        > </xsl:attribute-set>
        >
      • nosliwennaed
        Hi Steve, Sorry for the delay in replying, but I ve only just been able to start looking at the replies to my query. I tried to get to the information that you
        Message 3 of 12 , Feb 22, 2013
        • 0 Attachment
          Hi Steve,
          Sorry for the delay in replying, but I've only just been able to start looking at the replies to my query.

          I tried to get to the information that you provided in dropbox, but I get an error.

          I have a custom plugin so I will try to add the attribute and see what I get.

          I'll keep trying everyone's suggestions until I get the result I'm looking for and post again.

          Thanks,
          Deanne

          --- In dita-users@yahoogroups.com, Steven Calderwood <stevenc@...> wrote:
          >
          > Hi, Deanne,
          >
          > You need to add the following attribute to the of:block that holds the title content:
          > page-break-before="always"
          >
          > The best way to do is to add it to the attribute set for that particular topic title:
          >
          > xsl:attribute name="page-break-before">always</xsl:attribute>
          >
          > The best way to do that is through a custom plugin. You could use the Customization directory approach, but the plugin is preferred. Jarno has a very useful web application that generates custom plugins: https://dita-generator-hrd.appspot.com/pdf-plugin/
          >
          > And, yes, you can specify to what topics this attribute would apply to with some simple XSL. Here is the template that you want to beat out in priority:
          > https://dl.dropbox.com/u/39483865/title%20matching%20template.xsl
          >
          > In the match, you'd just specify a pattern that matches what you need (e.g., class value, node name).
          >
          > If you need further help with setting that up, I'd be glad to help you.
          >
          > Steve
          >
          >
          > From: nosliwennaed <nosliwennaed@...<mailto:nosliwennaed@...>>
          > Reply-To: "dita-users@yahoogroups.com<mailto:dita-users@yahoogroups.com>" <dita-users@yahoogroups.com<mailto:dita-users@yahoogroups.com>>
          > Date: Thursday, February 21, 2013 11:06 AM
          > To: "dita-users@yahoogroups.com<mailto:dita-users@yahoogroups.com>" <dita-users@yahoogroups.com<mailto:dita-users@yahoogroups.com>>
          > Subject: [dita-users] Adding page breaks to PDF
          >
          >
          >
          > Hi all,
          > I'm generating a couple of PDFs for a specific project and would like to know if there is a way to insert page breaks before topic titles to format the look and feel of my final documents so that they flow better (and the customer requested it).
          >
          > I've looked in Eliot's book for guidance, but didn't find anything specific to page breaks. So, I went straight to the commons-attr.xsl file (in my plugins folder) to see if I could figure it out on my own. I'm still a newbie with xsl, so no joy.
          >
          > The second part of the question is: if there is a way to add page breaks, is it all or nothing? That is, would there be a page break before every topic title, or could I specify that page breaks only occur before concept topics, or reference topics, or whatever.
          >
          > Oh, I'm using oXygen Author v13.2 to author my content, and DITA-OT 1.5.4 to generate output.
          >
          > Thanks,
          > Deanne
          >
        • Steven Calderwood
          Ah, the problem was the .xsl extension. It should be accessible now that it is a .txt: https://dl.dropbox.com/u/39483865/title%20matching%20template.txt Steven
          Message 4 of 12 , Feb 22, 2013
          • 0 Attachment
            Ah, the problem was the .xsl extension. It should be accessible now that it is a .txt:

            Steven

            -- 

            Steven Calderwood

            Content Management Engineer

            Human Kinetics

            217-351-5076 ext. 7830

            Direct Line: 217-403-7830

            stevenc@...


            From: nosliwennaed <nosliwennaed@...>
            Reply-To: "dita-users@yahoogroups.com" <dita-users@yahoogroups.com>
            Date: Friday, February 22, 2013 4:35 PM
            To: "dita-users@yahoogroups.com" <dita-users@yahoogroups.com>
            Subject: [dita-users] Re: Adding page breaks to PDF

             

            Hi Steve,
            Sorry for the delay in replying, but I've only just been able to start looking at the replies to my query.

            I tried to get to the information that you provided in dropbox, but I get an error.

            I have a custom plugin so I will try to add the attribute and see what I get.

            I'll keep trying everyone's suggestions until I get the result I'm looking for and post again.

            Thanks,
            Deanne

            --- In dita-users@yahoogroups.com, Steven Calderwood wrote:
            >
            > Hi, Deanne,
            >
            > You need to add the following attribute to the of:block that holds the title content:
            > page-break-before="always"
            >
            > The best way to do is to add it to the attribute set for that particular topic title:
            >
            > xsl:attribute name="page-break-before">always
            >
            > The best way to do that is through a custom plugin. You could use the Customization directory approach, but the plugin is preferred. Jarno has a very useful web application that generates custom plugins: https://dita-generator-hrd.appspot.com/pdf-plugin/
            >
            > And, yes, you can specify to what topics this attribute would apply to with some simple XSL. Here is the template that you want to beat out in priority:
            > https://dl.dropbox.com/u/39483865/title%20matching%20template.xsl
            >
            > In the match, you'd just specify a pattern that matches what you need (e.g., class value, node name).
            >
            > If you need further help with setting that up, I'd be glad to help you.
            >
            > Steve
            >
            >
            > From: nosliwennaed >
            > Reply-To: "dita-users@yahoogroups.comdita-users@yahoogroups.com>" dita-users@yahoogroups.comdita-users@yahoogroups.com>>
            > Date: Thursday, February 21, 2013 11:06 AM
            > To: "dita-users@yahoogroups.comdita-users@yahoogroups.com>" dita-users@yahoogroups.comdita-users@yahoogroups.com>>
            > Subject: [dita-users] Adding page breaks to PDF
            >
            >
            >
            > Hi all,
            > I'm generating a couple of PDFs for a specific project and would like to know if there is a way to insert page breaks before topic titles to format the look and feel of my final documents so that they flow better (and the customer requested it).
            >
            > I've looked in Eliot's book for guidance, but didn't find anything specific to page breaks. So, I went straight to the commons-attr.xsl file (in my plugins folder) to see if I could figure it out on my own. I'm still a newbie with xsl, so no joy.
            >
            > The second part of the question is: if there is a way to add page breaks, is it all or nothing? That is, would there be a page break before every topic title, or could I specify that page breaks only occur before concept topics, or reference topics, or whatever.
            >
            > Oh, I'm using oXygen Author v13.2 to author my content, and DITA-OT 1.5.4 to generate output.
            >
            > Thanks,
            > Deanne
            >

          • nosliwennaed
            Hi Steve, ... Am I right to assume that I will also have to run integrator.xml after I m finished with the template? I appreciate any help you can provide.
            Message 5 of 12 , Feb 25, 2013
            • 0 Attachment
              Hi Steve,
              I've added the attribute sets to my custom.xsl file located in ../plugins/fo/Customization/fo/attrs, and I've added the template to the custom.xsl file located in ../plugins/fo/Customization/fo/xsl; however, I don't know what you mean by the following (referring to the template):

              > In the match, you'd just specify a pattern that matches what you need (e.g., class value, node name).
              >

              Am I right to assume that I will also have to run integrator.xml after I'm finished with the template?

              I appreciate any help you can provide.

              Thanks,
              Deanne

              --- In dita-users@yahoogroups.com, Steven Calderwood <stevenc@...> wrote:
              >
              > Hi, Deanne,
              >
              > You need to add the following attribute to the of:block that holds the title content:
              > page-break-before="always"
              >
              > The best way to do is to add it to the attribute set for that particular topic title:
              >
              > xsl:attribute name="page-break-before">always</xsl:attribute>
              >
              > The best way to do that is through a custom plugin. You could use the Customization directory approach, but the plugin is preferred. Jarno has a very useful web application that generates custom plugins: https://dita-generator-hrd.appspot.com/pdf-plugin/
              >
              > And, yes, you can specify to what topics this attribute would apply to with some simple XSL. Here is the template that you want to beat out in priority:
              > https://dl.dropbox.com/u/39483865/title%20matching%20template.xsl
              >
              > In the match, you'd just specify a pattern that matches what you need (e.g., class value, node name).
              >
              > If you need further help with setting that up, I'd be glad to help you.
              >
              > Steve
              >
              >
              > From: nosliwennaed <nosliwennaed@...<mailto:nosliwennaed@...>>
              > Reply-To: "dita-users@yahoogroups.com<mailto:dita-users@yahoogroups.com>" <dita-users@yahoogroups.com<mailto:dita-users@yahoogroups.com>>
              > Date: Thursday, February 21, 2013 11:06 AM
              > To: "dita-users@yahoogroups.com<mailto:dita-users@yahoogroups.com>" <dita-users@yahoogroups.com<mailto:dita-users@yahoogroups.com>>
              > Subject: [dita-users] Adding page breaks to PDF
              >
              >
              >
              > Hi all,
              > I'm generating a couple of PDFs for a specific project and would like to know if there is a way to insert page breaks before topic titles to format the look and feel of my final documents so that they flow better (and the customer requested it).
              >
              > I've looked in Eliot's book for guidance, but didn't find anything specific to page breaks. So, I went straight to the commons-attr.xsl file (in my plugins folder) to see if I could figure it out on my own. I'm still a newbie with xsl, so no joy.
              >
              > The second part of the question is: if there is a way to add page breaks, is it all or nothing? That is, would there be a page break before every topic title, or could I specify that page breaks only occur before concept topics, or reference topics, or whatever.
              >
              > Oh, I'm using oXygen Author v13.2 to author my content, and DITA-OT 1.5.4 to generate output.
              >
              > Thanks,
              > Deanne
              >
            • Steven Calderwood
              Hi, Deanne, First, I apologize, I gave you the wrong template to override. You want to override the catch-all template in the mode processTopicTitle. This one:
              Message 6 of 12 , Feb 25, 2013
              • 0 Attachment
                Hi, Deanne,

                First, I apologize, I gave you the wrong template to override. You want to override the catch-all template in the mode processTopicTitle. This one:

                When you override it, you will need to do two things:
                1) Update the match attribute in the xsl:template tag. This should be the pattern that selects everything that you want to start on a new page. For example, if you want to force all reference topics to start on a new page, then your updated xsl:template tag would look like this:
                &lt;xsl:template match="*[contains(@class,' reference/reference ')]/*[contains(@class,' topic/title ')]" mode="processTopicTitle"&gt;

                If you want to break the page before every topic, then leave match as "*" and only do step 2.

                2) You need to edit the second fo:block element in the template so that it takes your new attribute set:
                &lt;fo:block xsl:use-attribute-sets="WHATEVER_YOUR_NEW_ATTRIBUTE_SET_NAME_IS"&gt;

                Here is an example that will apply the attribute-set named "steve" to every concept topic's title:

                You don't need to run integrator.xml if all you are doing is editing the custom.xsl file. That said, I think it is best practice to always run integrator.xml after modifying the toolkit.

                If you need more help, please feel free to contact me off list.

                Steven


                From: nosliwennaed <nosliwennaed@...>
                Reply-To: "dita-users@yahoogroups.com" <dita-users@yahoogroups.com>
                Date: Monday, February 25, 2013 10:35 AM
                To: "dita-users@yahoogroups.com" <dita-users@yahoogroups.com>
                Subject: [dita-users] Re: Adding page breaks to PDF

                 

                Hi Steve,
                I've added the attribute sets to my custom.xsl file located in ../plugins/fo/Customization/fo/attrs, and I've added the template to the custom.xsl file located in ../plugins/fo/Customization/fo/xsl; however, I don't know what you mean by the following (referring to the template):

                > In the match, you'd just specify a pattern that matches what you need (e.g., class value, node name).
                >

                Am I right to assume that I will also have to run integrator.xml after I'm finished with the template?

                I appreciate any help you can provide.

                Thanks,
                Deanne

                --- In dita-users@yahoogroups.com, Steven Calderwood wrote:
                >
                > Hi, Deanne,
                >
                > You need to add the following attribute to the of:block that holds the title content:
                > page-break-before="always"
                >
                > The best way to do is to add it to the attribute set for that particular topic title:
                >
                > xsl:attribute name="page-break-before">always
                >
                > The best way to do that is through a custom plugin. You could use the Customization directory approach, but the plugin is preferred. Jarno has a very useful web application that generates custom plugins: https://dita-generator-hrd.appspot.com/pdf-plugin/
                >
                > And, yes, you can specify to what topics this attribute would apply to with some simple XSL. Here is the template that you want to beat out in priority:
                > https://dl.dropbox.com/u/39483865/title%20matching%20template.xsl
                >
                > In the match, you'd just specify a pattern that matches what you need (e.g., class value, node name).
                >
                > If you need further help with setting that up, I'd be glad to help you.
                >
                > Steve
                >
                >
                > From: nosliwennaed >
                > Reply-To: "dita-users@yahoogroups.comdita-users@yahoogroups.com>" dita-users@yahoogroups.comdita-users@yahoogroups.com>>
                > Date: Thursday, February 21, 2013 11:06 AM
                > To: "dita-users@yahoogroups.comdita-users@yahoogroups.com>" dita-users@yahoogroups.comdita-users@yahoogroups.com>>
                > Subject: [dita-users] Adding page breaks to PDF
                >
                >
                >
                > Hi all,
                > I'm generating a couple of PDFs for a specific project and would like to know if there is a way to insert page breaks before topic titles to format the look and feel of my final documents so that they flow better (and the customer requested it).
                >
                > I've looked in Eliot's book for guidance, but didn't find anything specific to page breaks. So, I went straight to the commons-attr.xsl file (in my plugins folder) to see if I could figure it out on my own. I'm still a newbie with xsl, so no joy.
                >
                > The second part of the question is: if there is a way to add page breaks, is it all or nothing? That is, would there be a page break before every topic title, or could I specify that page breaks only occur before concept topics, or reference topics, or whatever.
                >
                > Oh, I'm using oXygen Author v13.2 to author my content, and DITA-OT 1.5.4 to generate output.
                >
                > Thanks,
                > Deanne
                >

              Your message has been successfully submitted and would be delivered to recipients shortly.