}
return baos.toByteArray();
}
private void content(PDF pd4ml, PageContext pc, OutputStream os) throws PageException, IOException {
ConfigWeb config = pc.getConfig();
pd4ml.useTTF("java:fonts", fontembed);
// body
if(!StringUtil.isEmpty(body,true)) {
// optimize html
URL base = getBase(pc);
try {
body=beautifyHTML(new InputSource(new StringReader(body)),base);
}catch (Throwable t) {}
pd4ml.render(body, os,base);
}
// srcfile
else if(srcfile!=null) {
if(StringUtil.isEmpty(strCharset))strCharset=pc.getConfig().getResourceCharset();
// mimetype
if(StringUtil.isEmpty(strMimetype)) {
String mt = ResourceUtil.getMimeType(srcfile,null);
if(mt!=null) setMimetype(mt);
}
InputStream is = srcfile.getInputStream();
try {
URL base = new URL("file://"+srcfile);
if(!localUrl){
//PageContext pc = Thread LocalPageContext.get();
String abs = srcfile.getAbsolutePath();
String contract = ContractPath.call(pc, abs);
if(!abs.equals(contract)) {
base=HTTPUtil.toURL(CGIImpl.getDomain(pc.getHttpServletRequest())+contract,true);
}
}
//URL base = localUrl?new URL("file://"+srcfile):getBase();
render(pd4ml, is,os,base);
}
catch (Throwable t) {}
finally {
IOUtil.closeEL(is);
}
}
// src
else if(src!=null) {
if(StringUtil.isEmpty(strCharset))strCharset="iso-8859-1";
URL url = HTTPUtil.toURL(src,true);
// set Proxy
if(StringUtil.isEmpty(proxyserver) && config.isProxyEnableFor(url.getHost())) {
ProxyData pd = config.getProxyData();
proxyserver=pd==null?null:pd.getServer();
proxyport=pd==null?0:pd.getPort();
proxyuser=pd==null?null:pd.getUsername();
proxypassword=pd==null?null:pd.getPassword();
}