![](/img/trans.png)
[英]How do I embed an SVG image inside another SVG image using Batik svggen?
[英]How do I superimpose one SVG image onto another using Apache Batik?
我需要使用Batik覆盖2个SVG文件。 一个文件用作背景图像,为308px×308px,而第二个文件(260px×260px)是必须居中的前景图像(即背景图像的中心)。 我希望将操作的结果保存在第三个SVG文件中。 如果您熟悉Batik,我会很感激您的建议。
谢谢,
奥利维尔。
如果您不需要在最后一个文档中包含背景和前景文档的内容,您可以使用它们:
<svg xmlns='http://www.w3.org/2000/svg'
xmlns:xlink='http://www.w3.org/1999/xlink'
width='308' height='308' viewBox='0 0 308 308'>
<image xlink:href='background.svg' width='308' height='308'/>
<image xlink:href='foreground.svg' x='24' y='24' width='260' height='260'/>
</svg>
使用DOM构建此文档应该很简单。 有关使用DOM API构建文档的示例,请参见此处 。
如果您需要将两个文档合并为一个,那么您可以:
Document
resulting from parsing background.svg 让 = 解析 background.svg得到的Document
Document
resulting from parsing foreground.svg 令 =解析foreground.svg得到的Document
a.
让 = a.
importNode
(b.getDocumentElement(), true)
x
和y
属性设置为“24” a.getDocumentElement().appendChild(e)
is a document with the foreground contents merged in. 现在是一个合并了前景内容的文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.