繁体   English   中英

如何使用Apache Batik将一个SVG图像叠加到另一个上?

[英]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构建文档的示例,请参见此处

如果您需要将两个文档合并为一个,那么您可以:

  • = the Document resulting from parsing background.svg = 解析 background.svg得到的Document
  • = the Document resulting from parsing foreground.svg =解析foreground.svg得到的Document
  • = a. = a. importNode (b.getDocumentElement(), true)
  • to "24" xy属性设置为“24”
  • 调用a.getDocumentElement().appendChild(e)

is a document with the foreground contents merged in. 现在是一个合并了前景内容的文档。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM