if (this.multiFileUtil != null) {
prepareHandlerWithOutputStream(index);
} else {
if (this.simpleResult == null) {
//Only one page is supported with this approach at the moment
throw new IFException(
"Only one page is supported for output with the given Result instance!",
null);
}
super.setResult(this.simpleResult);
this.simpleResult = null;
}
try {
handler.startDocument();
handler.startPrefixMapping("", NAMESPACE);
handler.startPrefixMapping(XLINK_PREFIX, XLINK_NAMESPACE);
AttributesImpl atts = new AttributesImpl();
XMLUtil.addAttribute(atts, "version", "1.1"); //SVG 1.1
/*
XMLUtil.addAttribute(atts, "index", Integer.toString(index));
XMLUtil.addAttribute(atts, "name", name);
*/
XMLUtil.addAttribute(atts, "width", SVGUtil.formatMptToPt(size.width) + "pt");
XMLUtil.addAttribute(atts, "height", SVGUtil.formatMptToPt(size.height) + "pt");
XMLUtil.addAttribute(atts, "viewBox",
"0 0 " + SVGUtil.formatMptToPt(size.width)
+ " " + SVGUtil.formatMptToPt(size.height));
handler.startElement("svg", atts);
try {
Transformer transformer = tFactory.newTransformer();
Source src = new DOMSource(this.reusedParts.getDocumentElement());
Result res = new SAXResult(new DelegatingFragmentContentHandler(this.handler));
transformer.transform(src, res);
} catch (TransformerConfigurationException tce) {
throw new IFException("Error setting up a Transformer", tce);
} catch (TransformerException te) {
if (te.getCause() instanceof SAXException) {
throw (SAXException)te.getCause();
} else {
throw new IFException("Error while serializing reused parts", te);
}
}
} catch (SAXException e) {
throw new IFException("SAX error in startPage()", e);
}
}