1

I have been trying hard to find a solution to this but no luck till now. I'm generating a PDF from xml and I want to float the images inside the pdf. Like for example if I have image floating left in the xml, same should get applied into the pdf.

<p>
<img width="127" height="190" src="/images/241729.jpg" style="float: left;">
Globally transition high standards in technology via ubiquitous partnerships.
Distinctively pursue worldwide paradigms vis-a-vis business e-business.
</p> 

and the XSL that I have now looks like

<xsl:template match="img">
    <xsl:param name="src">
      <xsl:choose>
        <xsl:when test="substring-before(@src,'://') = 'http'"><xsl:value-of select="@src" /></xsl:when>
    <xsl:otherwise>
      <xsl:choose>
        <xsl:when test="substring(@src, 1, 1) != '/' "><xsl:value-of select="@src" /></xsl:when>
        <xsl:otherwise><xsl:value-of select="@src" /></xsl:otherwise>
      </xsl:choose>
    </xsl:otherwise>
      </xsl:choose>
    </xsl:param>

    <fo:block space-after="12pt">
      <fo:external-graphic src="{$src}">
        <xsl:if test="@width">
          <xsl:attribute name="width">
            <xsl:choose>
              <xsl:when test="contains(@width, 'px')">
                <xsl:value-of select="@width"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="concat(@width, 'px')"/>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:attribute>
        </xsl:if>
        <xsl:if test="@height">
          <xsl:attribute name="height">
            <xsl:choose>
              <xsl:when test="contains(@height, 'px')">
                <xsl:value-of select="@height"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="concat(@height, 'px')"/>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:attribute>
        </xsl:if>
      </fo:external-graphic>
    </fo:block>
  </xsl:template>

I'm trying to add <fo:float> in this template match but it's not working the way it should. It would be great if you can tell me how to approach this problem.

4

0 回答 0