我正在使用Apache FOP生成PDF。我的数据在XML文件中,我使用XSL样式表来呈现它。我在样式表中使用SVG时遇到问题。我创建了一个
的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 :(得分: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>
答案 1 :(得分: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>