You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Lim Huat Heng <li...@bizsol.com.my> on 2003/08/27 18:03:46 UTC

Seek help

Anyone who may help
    I have read the article on HTML to Formatting Objects(FO) conversion guide, in fact, it helps a lot in my understanding to prepare for the task to produce a PDF report from an existing HTML report. 
    However I would like to consult anyone who may help on a few things and hope that you can advice. When using a table, based on the XSLT, it requires the attribute cols, in which it will specify the total columns and width for each column. If  the table is generated dynamically (the total is unknown in advance), will I be able to pass the total no of columns to the XSLT during runtime and will it auto allocate each column equal width? Currently I get ArrayIndexOutOfBound error when the column is more than 2 and cols is not specified.

  I try to add a 'dummy' attribute noOfCols to the HTML's table tag, as in <table width="100%" border="0" cellspacing="5" cellpadding="1" noOfCols="<%=noOfCols%>">. Then I try to edit your XSL such that if there's noOfCols, then I will calculate the table column width as 795 divided by the total no of columns. Otherwise, if cols exist, then the original process is unchanged.Is the XsL correct? I guess the division is wrong, how can I solve it?
  
  <xsl:template match="table">
    <fo:table table-layout="fixed">
      <xsl:choose>        
        <xsl:when test="@cols">
          <xsl:call-template name="build-columns">
            <xsl:with-param name="cols" 
             select="concat(@cols, ' ')"/>
          </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
          <xsl:variable name="colWidth">
          <xsl:choose>
            <xsl:when test="@noOfCols">
              <xsl:number value="@noOfCols"/>   
            </xsl:when>
            <xsl:otherwise>
              <xsl:number value="55"/>
            </xsl:otherwise>  
          </xsl:choose>
          <fo:table-column column-width="$colWidth"/> <!-- LHH Modified 200 -->  
          </xsl:variable>
        </xsl:otherwise>
      </xsl:choose>     
      <fo:table-body>
        <xsl:apply-templates select="*"/>
      </fo:table-body>
    </fo:table>
  </xsl:template>

    Besides, when I try to generate a report that is 100 pages long, it took almost 5 minutes to get the report rendered and my web server consume about 150MB of RAM. Is there a way I could improve this? Lastly, when I have some punctuations in the data, in particularly '&' (so far that's what I found), I get the following error: 

    HTML2PDFServlet.doGet: javax.servlet.ServletException: org.xml.sax.SAXParseException: Illegal character or                      entity reference syntax.
    Is it due to Java or XML? Please advice. Thanks.