javax.xml.transform.Result result = new StreamResult(out);
// deep clone document
SVGDocument doc = (SVGDocument) DOMUtilities.deepCloneDocument(getDocument(), getDocument().getImplementation());
NodeList imgs = doc.getElementsByTagNameNS(SVGConstants.SVG_NAMESPACE_URI, SVGConstants.SVG_IMAGE_TAG);
final String tmpurl = new File(System.getProperty("java.io.tmpdir") + File.separator).toURI().toString();
for(Node img : new XMLNodeListIterator(imgs)) {
if(img instanceof Element) {
try {
Element i = (Element) img;
String href = i.getAttributeNS(SVGConstants.XLINK_NAMESPACE_URI, SVGConstants.XLINK_HREF_ATTRIBUTE);
if(href.startsWith(tmpurl) && href.endsWith(".png")) {