Мое решение
private static class UserAgentCallback extends ITextUserAgent {
public UserAgentCallback(ITextOutputDevice outputDevice, SharedContext sharedContext) {
super(outputDevice);
setSharedContext(sharedContext);
}
@Override
public String resolveURI(String uri) {
return uri;
}
@Override
protected InputStream resolveAndOpenStream(String uri) {
java.io.InputStream is = null;
URL url = null;
try {
url = new ClassPathResource("/META-INF/pdfTemplates/" + uri).getURL();
} catch (IOException e) {
XRLog.exception("bad URL given: " + uri, e);
}
if (url == null) {
XRLog.load("Didn't find resource [" + uri + "].");
return null;
}
try {
is = url.openStream();
} catch (java.net.MalformedURLException e) {
XRLog.exception("bad URL given: " + uri, e);
} catch (java.io.FileNotFoundException e) {
XRLog.exception("item at URI " + uri + " not found");
} catch (java.io.IOException e) {
XRLog.exception("IO problem for " + uri, e);
}
return is;
}
}
и вызов:
renderer.getSharedContext()
.setUserAgentCallback(new UserAgentCallback(renderer.getOutputDevice(), renderer.getSharedContext()));