[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 440
  • Last Modified:

Help! - Coverting From HTML to PDF using XSL FO - valign not working

Hi there,

I'm using the FOP from xml.apache.org/fop tool to convert from HTML
to PDF.

I'm reading the height and valign attributes of a column-cell (TD) in the XSL

 <xsl:attribute-set name="table.data.td">
        <xsl:attribute name="border-style">solid</xsl:attribute>
     <xsl:attribute name="border-width">0pt</xsl:attribute>
     <xsl:attribute name="padding-start">0.3em</xsl:attribute>
     <xsl:attribute name="padding-end">0.2em</xsl:attribute>
     <xsl:attribute name="padding-before">2pt</xsl:attribute>
     <xsl:attribute name="padding-after">2pt</xsl:attribute>

<!-- HTML table tag <td> -->
<xsl:template match="td">
  <fo:table-cell xsl:use-attribute-sets="table.data.td">
      <xsl:if test="@valign">
         <xsl:attribute name="display-align">
          <xsl:value-of select="@valign"/>
       <xsl:if test="@height">
         <xsl:attribute name="height">
         <xsl:value-of select="concat(@height,'px')"/>
       <xsl:if test="@class='smalltextwb'">
      <xsl:attribute name="font-family">Verdana, Arial, Helvetica, sans-serif</xsl:attribute>
         <xsl:attribute name="font-size">10px</xsl:attribute>
       <xsl:attribute name="font-weight">normal</xsl:attribute>
       <xsl:attribute name="color">#FFFFFF</xsl:attribute>
            <xsl:if test="@align">
               <xsl:attribute name="text-align">
                  <xsl:value-of select="@align"/>

When the pdf is generated, the valign doesnt work when the height is mentioned
on the HTML:

<td height="100" valign="center"> --> Doesnt work

<td valign="center"> --> works

Does anyone has any idea why the height property prevents the aligning
of the column cell on the PDF?

Tell me if you need more information

Any help will be great,
1 Solution
i don;t think this wil support html to PDF conversion. it supports xml to PDF

the following sourceforge might help you


or else there is and odd way of doing it
install PDF writer and make it as your default PDF writer
open the html using Runtime API of java
on load call print function.
so the PDF file will be created same as HTML

hope this help

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now