Page 1 of 1
<indexterm> element causes extra whitespace in PDF
Posted: Mon Sep 12, 2022 9:04 pm
by ahiggins
Hi,
I'm not sure if this is the right place to ask or if you can direct me to another forum. I use Oxygen XML v.24 with DITA-OT3.7 and use XSL FO to transform PDFs. When a paragraph (<p> element) contains only <indexterm> elements, it creates a whitespace in the PDF output. For the following example, a line of whitespace appears between the short description and the first paragraph.
Code: Select all
<concept id="lawnmowerconcept" xml:lang="en-us">
<title>Lawnmower</title>
<shortdesc>The lawnmower is a machine used to cut grass in the yard.</shortdesc>
<conbody>
<p><indexterm>indexterm</indexterm></p>
<p>Lawnmowers can be electric, gas-powered, or manual.</p>
</conbody>
</concept>
I looked at the index.xsl file in the org.dita.pdf2 plugin but I can't figure out if I need to make a change to that file or different one. I appreciate any help.
Thanks,
Amy
Re: <indexterm> element causes extra whitespace in PDF
Posted: Tue Sep 13, 2022 7:52 am
by Radu
Hi Amy,
How about if the paragraph is empty, without indexterm inside it?
Because I would also expect an empty paragraph (with no text or elements inside it) to produce some kind of extra space there, as each paragraph has certain margins.
How about if you define the index terms in the topic prolog section instead of creating extra paragraphs just to define them?
For the Oxygen User's Manual we usually define them in the prolog section like:
Code: Select all
<topic id="preferences-xml">
<title>XML Preferences</title>
<prolog>
<metadata>
<keywords><indexterm>Preferences</indexterm></keywords>
</metadata>
</prolog>
<body>
<p>This section describes the panels that contain the user preferences related with XML.</p>
</body>
</topic>
Regards,
Radu
Re: <indexterm> element causes extra whitespace in PDF
Posted: Tue Sep 13, 2022 1:56 pm
by chrispitude
If you have too many <indexterm>-in-<p> instances in your content to fix manually, you could create a refactoring operation to move them to a <prolog> element for you.
If you are not sure how to do this, I can help.
Re: <indexterm> element causes extra whitespace in PDF
Posted: Tue Sep 20, 2022 7:27 pm
by ahiggins
Thanks to both of you for your help. We do want to keep our indexterms in separate paragraphs for specific situations because it gives the option to link a group of indexterms to a location in the middle of a page.
So far, this xsl code seems to solve the issue of blank lines caused by <p> elements consisting only of <indexterms>.
Code: Select all
<xsl:template match="*[contains(@class, ' topic/p ')]">
<xsl:if test="child::*/@class | child::text()">
<fo:block xsl:use-attribute-sets="p">
<xsl:call-template name="commonattributes"/>
<xsl:apply-templates/>
</fo:block>
</xsl:if>
</xsl:template>
Re: <indexterm> element causes extra whitespace in PDF
Posted: Wed Sep 21, 2022 7:34 am
by Radu
Hi,
I'm not sure how a condition like this
child::*/@class would help as it also matches an <indexterm> element as all DITA elements have @class attributes defined on them.
Maybe leave that template which matches the paragraph as it originally was and add an extra template which ignores all paragraphs which have no text and have all child elements with name "indexterm":
Code: Select all
<xsl:template match="*[contains(@class, ' topic/p ')][string-length(string-join(text(), '')) = 0][count(*) = count(*[local-name()='indexterm'])]"/>
But is that specific indexterm taken into account anymore in the generated PDF if we filter it out in this stage?
Regards,
Radu