final XMLSerializer serializer = new XMLSerializer();
serializer.setOutputByteStream(tempOut);
try {
serializer.serialize(document);
} catch (final IOException e) {
throw new FontException("Error serializing DOM: " + e.getMessage());
}
final byte[] serializedDOM = tempOut.toByteArray();
/* Pretty print. */
final ByteArrayInputStream inputStream = new ByteArrayInputStream(
serializedDOM);
final InputSource prettyInput = new InputSource(inputStream);
final FOrayPretty pretty = new FOrayPretty(prettyInput, output,
null);
try {
pretty.start();
} catch (final IOException e) {
throw new FontException(e);
} catch (final SAXException e) {
throw new FontException(e);
} catch (final ParserConfigurationException e) {
throw new FontException(e);
}
}