2013-07-12 79 views
0

我正在使用Apache FOP生成PDF。我的數據在XML文件中,我使用XSL樣式表來呈現它。我在樣式表中使用SVG時遇到了問題。我創建了一個SVG,它是在XSL樣式表中使用SVG

<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.0" width="400" height="400" id="svg2"> 
<path d="M200,200 L390,200 A190,190 0 0,1 200,390 z" fill="red" stroke="black" stroke-width="2" fill-opacity="0.5" stroke-linejoin="round" /> 
<path d="M200,200 L200,390 A190,190 0 0,1 10,200 z" fill="orange" stroke="black" stroke-width="2" fill-opacity="0.5" stroke-linejoin="round" /> 
<path d="M200,200 L10,200 A190,190 0 0,1 200,10 z" fill="yellow" stroke="black" stroke-width="2" fill-opacity="0.5" stroke-linejoin="round" /> 
<path d="M200,200 L200,10 A190,190 0 0,1 390,200 z" fill="green" stroke="black" stroke-width="2" fill-opacity="0.5" stroke-linejoin="round" /> 
</svg> 

但是,如何將它放在樣式表中。我試圖把它放在一個<fo:instream-foreign-object>

<fo:instream-foreign-object xmlns:svg="http://www.w3.org/2000/svg"> 
    <svg:svg width="400" height="400"> 
    <svg:path d="M200,200 L390,200 A190,190 0 0,1 200,390 z" fill="red" stroke="black" stroke-width="2" fill-opacity="0.5" stroke-linejoin="round" /> 
... 
    </svg:svg> 
</fo:instream-foreign-object> 

但這不起作用。有誰知道我做錯了什麼?

+0

'路徑的'應該工作,這是他們如何做到這一點在他們的一個示例中:http://xmlgraphics.apache.org/fop/dev/fo/embedding.fo(使用視圖源)。請註明「不起作用」,這太含糊。 – Tomalak

回答

0

。做正確的做法是,而不是做

<svg:path stroke="black" stroke-width="2" fill-opacity="0.5" stroke-linejoin="round" /> 

您需要繪製這樣

<svg:path stroke="black" stroke-width="2" fill-opacity="0.5" stroke-linejoin="round"> 
    <xsl:attribute name="fill">red</xsl:attribute> 
    <xsl:attribute name="d">M200,200 L390,200 A190,190 0 0,1 200,390 z</xsl:attribute> 
</svg:path> 
0

他是我的內FOP的信紙大小的背景(文本「背景區域」)SVG的例子:它原來我做的一切都是錯的

<fo:block-container absolute-position="absolute" 
     top="0in" left="0in" width="8.5in" height="11in" 
     content-height="scale-to-fit" content-width="scale-to-fit" 
     scaling="non-uniform" 
     background-position="center" background-repeat="no-repeat" 
     background-image="url(your_xml_file.svg)"> 
    <fo:block>background region 
    </fo:block> 
    </fo:block-container>