Element i = (Element) img;
String href = i.getAttributeNS(SVGConstants.XLINK_NAMESPACE_URI, SVGConstants.XLINK_HREF_ATTRIBUTE);
if(href.startsWith(tmpurl) && href.endsWith(".png")) {
// need to convert the image into an inline image.
ByteArrayOutputStream os = new ByteArrayOutputStream();
Base64EncoderStream encoder = new Base64EncoderStream(os);
File in = new File(new URI(href));
FileInputStream instream = new FileInputStream(in);
byte[] buf = new byte[4096];
while(true) {
int read = instream.read(buf, 0, buf.length);
if(read <= 0) {
break;
}
encoder.write(buf, 0, read);
}
instream.close();
encoder.close();
// replace HREF with inlined image data.
i.setAttributeNS(SVGConstants.XLINK_NAMESPACE_URI, SVGConstants.XLINK_HREF_ATTRIBUTE, SVGSyntax.DATA_PROTOCOL_PNG_PREFIX + os.toString());
}
}
catch(URISyntaxException e) {