Search in sources :

Example 1 with ResourceResolver

use of org.apache.xmlgraphics.io.ResourceResolver in project grafikon by jub77.

the class PdfTransformer method convertResolver.

private static ResourceResolver convertResolver(URIResolver uriResolver) {
    return new ResourceResolver() {

        @Override
        public Resource getResource(URI uri) throws IOException {
            String asciiUri = uri.toASCIIString();
            InputStream is = PdfTransformer.class.getClassLoader().getResourceAsStream(asciiUri);
            if (is == null && uriResolver != null) {
                try {
                    StreamSource streamSource = (StreamSource) uriResolver.resolve(asciiUri, null);
                    if (streamSource != null) {
                        is = streamSource.getInputStream();
                    }
                } catch (TransformerException e) {
                    throw new IOException(e);
                }
            }
            return is == null ? null : new Resource(is);
        }

        @Override
        public OutputStream getOutputStream(URI uri) throws IOException {
            return null;
        }
    };
}
Also used : InputStream(java.io.InputStream) StreamSource(javax.xml.transform.stream.StreamSource) ResourceResolver(org.apache.xmlgraphics.io.ResourceResolver) Resource(org.apache.xmlgraphics.io.Resource) IOException(java.io.IOException) URI(java.net.URI)

Aggregations

IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URI (java.net.URI)1 StreamSource (javax.xml.transform.stream.StreamSource)1 Resource (org.apache.xmlgraphics.io.Resource)1 ResourceResolver (org.apache.xmlgraphics.io.ResourceResolver)1