assertEquals(100000, info.getSize().getHeightMpt());
}
public void testSVGWithDOM() throws Exception {
String uri = "my:SVGImage";
FOUserAgent userAgent = fopFactory.newFOUserAgent();
userAgent.setURIResolver(new URIResolver() {
public Source resolve(String href, String base) throws TransformerException {
if (href.startsWith("my:")) {
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
Document doc = impl.createDocument(svgNS, "svg", null);
Element element = doc.getDocumentElement();
element.setAttribute("viewBox", "0 0 20 20");
element.setAttribute("width", "20pt");
element.setAttribute("height", "20pt");
Element rect = doc.createElementNS(svgNS, "rect");
rect.setAttribute("x", "5");
rect.setAttribute("y", "5");
rect.setAttribute("width", "10");
rect.setAttribute("height", "10");
element.appendChild(rect);
DOMSource src = new DOMSource(doc);
return src;
} else {
return null;
}
}
});
ImageManager manager = fopFactory.getImageManager();
ImageInfo info = manager.preloadImage(uri, userAgent.getImageSessionContext());
assertNotNull("ImageInfo must not be null", info);
assertEquals(MimeConstants.MIME_SVG, info.getMimeType());
assertEquals(uri, info.getOriginalURI());
assertEquals(20, info.getSize().getWidthPx()); //100 = default viewport size
assertEquals(20, info.getSize().getHeightPx());
assertEquals(userAgent.getSourceResolution(), info.getSize().getDpiHorizontal(), 0.1);
assertEquals(20000, info.getSize().getWidthMpt());
assertEquals(20000, info.getSize().getHeightMpt());
}