Author: jleroux Date: Wed Mar 4 13:11:41 2015 New Revision: 1663979 URL: http://svn.apache.org/r1663979 Log: An improved patch from Christian Carlow for "Allow FOP to support <fo:external-graphic></fo:external> for -Dportoffset" https://issues.apache.org/jira/browse/OFBIZ-6120
FOP <fo:external-graphic/> images do not appear when portoffset used: 2015-02-28 18:12:12,249 |http-bio-8445-exec-4 |ApacheFopWorker |I| FOP FontBaseURL: file:/home/anon/workspace/ofbiz/framework/webapp/config/ 2015-02-28 18:12:12,254 |http-bio-8445-exec-4 |FOP |D| target-resolution set to: 72.0dpi (px2mm=0.35277778) 2015-02-28 18:12:12,593 |http-bio-8445-exec-4 |FOP |E| Error with opening URL 'http://localhost:8080/content/control/stream?contentId=10004': Connection refused 2015-02-28 18:12:12,616 |http-bio-8445-exec-4 |FOUserAgent |E| Image not found. URI: /content/control/stream?contentId=10004. (See position 40:158) In framework/webapp/config/fop.xconf <base>http://localhost:8080</base> is hardcoded This patch employs FopFactory.setBaseUrl() along with the portOffset from Start class. A better solution might be to extract the port from the baseUrl of fop.xconf and then apply the offset to that but I don't have time to implement that yet. jleroux: I followed Christian's tip to complete his patch Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java?rev=1663979&r1=1663978&r2=1663979&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java Wed Mar 4 13:11:41 2015 @@ -41,6 +41,7 @@ import org.apache.fop.apps.Fop; import org.apache.fop.apps.FopFactory; import org.apache.fop.apps.MimeConstants; import org.ofbiz.base.location.FlexibleLocation; +import org.ofbiz.base.start.Start; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.FileUtil; import org.ofbiz.base.util.UtilProperties; @@ -82,6 +83,10 @@ public class ApacheFopWorker { File userConfigFile = FileUtil.getFile(ofbizHome + fopPath + "/fop.xconf"); if (userConfigFile.exists()) { fopFactory.setUserConfig(userConfigFile); + URL baseUrl = new URL(fopFactory.getBaseURL()); + Integer baseport = baseUrl.getPort(); + Integer port = baseport + Start.getInstance().getConfig().portOffset; + fopFactory.setBaseURL("http://localhost:" + port); } else { Debug.logWarning("FOP configuration file not found: " + userConfigFile, module); }

