Apache FOP is the tool being used in Standard CRM installation to generate the PDF reports. The phenomenon works on the basis of Extended Style sheet Transformation methodology. We had posted the detailed information on this topic before. Please go through the below link to refer the same.
http://sagecrmaddons.blogspot.com/2009/07/file-to-pdf-conversion-using-fop.html
As per the block diagram in above post, we need to provide XML file as well as style sheet file as input to FOP server and apply fonts level styling to achieve the output in PDF format. There is java command that we can run at command prompt to achieve this. Now as this is command being run on windows level how feasible it is to make it work on web level. Yes, this can be achieved using Shell object of WScript. The below example explains how to achieve the same in ASP.
Asp code :
var xslcompletestylesheetpath=”
var xmlfullpath=”
var pdffullpath=”
//Intialize string for Java command
var javastr=””;
//’Create object of shell command
var oShell=new ActiveXObject(“WScript.Shell”);
//’Create a string to be passed to FOP
javastr = “java -Xmx128m -cp C:\PROGRA~1\FOP\build/fop.jar;”
javastr += “C:\PROGRA~1\FOP\lib\xml-apis.jar;”
javastr += “C:\PROGRA~1\FOP\lib\xercesImpl-2.2.1.jar;”
javastr += “C:\PROGRA~1\FOP\lib\xalan-2.4.1.jar;”
javastr += “C:\PROGRA~1\FOP\lib\batik.jar;”
javastr += “C:\PROGRA~1\FOP\lib\avalon-framework-cvs-20020806.jar org.apache.fop.apps.Fop”
javastr += ” -xsl “”+ xslcompletestylesheetpath + “” -xml “”+ xmlfullpath + “” -pdf “” + pdffullpath +”””
javastr += ” -c C:\Progra~1\FOP\conf/userconfig.xml”
//’Run shell command to generate PDF from fop
var intReturn1 = oShell.run(javastr,3,true)
The good thing here is, the conversion takes place on CRM server side that too in silent mode. Only thing you need to have is the XML and FOP based style sheet file to be passed as an input to FOP server. These are required to achieve the required XSL transformation.
Happy scripting!! 🙂