oxygenxml / dita-ot-css-pdf

Plugin that converts DITA Maps to PDF using CSS 3 stylesheets.
Apache License 2.0
17 stars 8 forks source link

Spanned table rows do not seem to work #10

Closed markgif closed 8 years ago

markgif commented 8 years ago

I have a DITA table with spanned rows using @morerows like the sample below. The spanned rows are not respected in the PDF (attached). In searching through the CSS code I can't find "morerows" so I assume it's not implemented. How can I fix this?

Thanks, Mark

table.pdf

<concept id="table-test" xml:lang="en">
  <title>Table test</title>
  <shortdesc>The following chart is a quick overview. </shortdesc>
  <conbody>
    <table outputclass="type2">
      <tgroup cols="3">
        <colspec colname="1" />
        <colspec colname="2" />
        <colspec colname="3" />
        <thead>
          <row>
            <entry colname="1" nameend="1" namest="1">First Column</entry>
            <entry>Second Column</entry>
            <entry>Third Column</entry>
          </row>
        </thead>
        <tbody>
          <row>
            <entry morerows="1">You need other help </entry>
            <entry>Hospital stay </entry>
            <entry>Text</entry>
          </row>
          <row>
            <entry>Doctor or surgeon care </entry>
            <entry>Text</entry>
          </row>
        </tbody>
      </tgroup>
    </table>
  </conbody>
</concept>
grefel commented 8 years ago

We had the same issue and could not find a solution with CSS. We changed the output-data via a custom XSLT. Basically <entry> -> <td>. This breaks the merged Dita-Strucure but works for us with Prince XML. But maybe there is a better solution out there. The template we're using:

<xsl:template match="entry">
    <td xmlns="http://www.w3.org/1999/xhtml">
        <xsl:copy-of select="@*"/>
        <xsl:if test="@morerows">
              <xsl:attribute name="rowspan" select="number(@morerows) + 1"></xsl:attribute>  
        </xsl:if>
        <xsl:if test="@namest and @nameend">
            <xsl:variable name="namest" select="@namest"/>
            <xsl:variable name="nameend" select="@nameend"/>
            <xsl:variable name="namestPos" select="number(parent::*/parent::*/parent::*/colspec[@colname=$namest]/@colnum)"/>
            <xsl:variable name="nameendPos" select="number(parent::*/parent::*/parent::*/colspec[@colname=$nameend]/@colnum)"/>
            <xsl:attribute name="colspan" select="$nameendPos - $namestPos + 1"/>  
        </xsl:if>
        <xsl:apply-templates/>
    </td>
</xsl:template>
markgif commented 8 years ago

Thanks very much. That might work for me.

What PDF processor are you using? I'm using Antenna House and I'm thinking about asking them to implement awareness of DITA/CALS @morerows etc. so I don't have to do this.

grefel commented 8 years ago

Sorry missed the processor out: I use Prince XML.

dan-caprioara commented 8 years ago

Indeed, this is a CSS limitation. There is no way to specify the column and row span of the table cells. I will integrate the fix proposed by grefel. (but I have to test it also with AntennaHouse)

dan-caprioara commented 8 years ago

I just tested with Prince and Antenna House and both have non-standard CSS extensions for imposing colspan and rowspan to table cells:

http://www.princexml.com/doc/properties/table-column-span/

    *[class~="topic/entry"][colspan] {
       table-column-span:attr(colspan);
    }
    *[class~="topic/entry"][rowspan] {
       table-row-span:attr(rowspan);
    }

The above XSLT template is still needed, but works fine without converting the CALS 'entry' to HTML 'td'.