2016-12-01 4 views
2

Ich konvertiere einige HTML in eine PDF mit XSLT. Ich bekomme unerwünschte Zeilenumbrüche, und ich weiß nicht warum. HierUnerwünschte Zeilenumbrüche in PDF-Dateien, die mit XSL-FO erstellt wurden?

ist die HTML-Quelle:

<li><strong>must</strong> only work in the occupation and for 
    the sponsor with the most recently approved nomination for 
    the holder <strong>unless</strong> the visa holder's 
    occupation is specified on a relevant instrument; 
</li> 

und hier ist, wie es in einem Browser aussieht:

enter image description here

Hier sind einige der XSLT:

<xsl:template match="condition/div"> 
    <xsl:apply-templates select="div|p|ul|li|a|ol|strong"/> 
</xsl:template> 

<xsl:template match="li" mode="bullet"> 
    <fo:list-item> 
      Unicode Bullet Character 
      <fo:list-item-label end-indent="label-end()"> 
       <fo:block> 
        &#x2022; 
       </fo:block> 
      </fo:list-item-label> 
      <fo:list-item-body start-indent="body-start()"> 
       <fo:block font-size="8pt" padding-bottom="2mm" padding-top="1mm"> 
        <xsl:apply-templates /> 
       </fo:block> 
      </fo:list-item-body> 
    </fo:list-item> 
</xsl:template> 

<xsl:template match="strong"> 
    <fo:block font-weight="bold">  
     <xsl:value-of select="." />  
    </fo:block> 
</xsl:template> 

... und so sieht die Ausgabe aus:

enter image description here

Wie Sie sehen können, erscheinen unerwünschte Zeilenumbrüche nach den <strong> Tags. Irgendwelche Ideen, wie man das verhindern kann?

Antwort

2

Sie wollen fo:inline (wie span in HTML) hier statt fo:block (wie div in HTML).

ändern

<xsl:template match="strong"> 
    <fo:block font-weight="bold">  
     <xsl:value-of select="." />  
    </fo:block> 
</xsl:template> 

zu

<xsl:template match="strong"> 
    <fo:inline font-weight="bold">  
     <xsl:value-of select="." />  
    </fo:inline> 
</xsl:template> 

die Zeilenumbrüche nach strong zu beseitigen.

+3

Ich liebe Stackoverflow und ich liebe kjhughes. :) –

Verwandte Themen