Some thoughts on Sage CRM, FOP, PDF and Reports

Hints, Tips and Tricks

Technical Hints Tips and Tricks that cover customization and development using Sage CRM. API usage and coding are covered.

Some thoughts on Sage CRM, FOP, PDF and Reports

  • Comments 9
  • Likes
Sage CRM uses Apache FOP (Formatting Objects Processor) to generate its reports in PDF format. 


FOP is an example of a print formatter that uses XSL formatting objects (XSL-FO) and is in theory not tied to outputting in a particular format, although its usage in Sage CRM is designed around creating PDF files.

When Sage CRM is installed it gets installed with it in the

C:\Program Files\FOP


The interaction with FOP for the reports creation is controlled within the Administration area under

Administration -> E-mail and Documents -> Documents & Reports Configuration

We can see that FOP is called via a batch file (FOP.bat) and this in turn calls the Java application that reads a formatting object (FO) tree and renders the resulting pages to PDF.

We can see where the "Adobe Converter Parameter String" field in the screen shot above reads

-q %1 %2

The -q means quiet mode. The %1 is the input file and the %2 is the output file.

The input file is created in the folder
C:\Program Files\Sage\CRM\[installname]\WWWRoot\Temp\Temporary Report Files

initially as a tmp file and then as an XML file.

The output file is then created in

C:\Program Files\Sage\CRM\[installname]\WWWRoot\Temp\Temporary Adobe Files

Once the file has been converted the temp XML file is removed.

In theory you may be able to use FOP directly yourself within an ASP page.

A simple way of use FOP to generate PDF files is to use the inbuilt Sage CRM actions. For example if you have a need to create a Report like a Summary Report button on a custom new entity then you could add a button to the ASP page. Like this:

//Example to show how to build a button that calls a custom report from a screen.
//intReportAction is either 1410 to display the report options or 1411 to directly run the report
//var intReportAction = 1410;
var intReportAction = 1411;
//Allowed values for strDestination are "Screen", "Adobe", "CSV", "Excel"
var strDestination = "Adobe";
var strSummaryReportButton = CRM.Button("Print to Excel", "executesummaryreport.gif", CRM.URL(intReportAction)+"&Key41=31&FlgNewWindow=True&Destination="+strDestination+"&PageSize=210x297&Orientation=Landscape", "", "", "EWARE_HELP")


The Action code 1411 means that the report is generated as a PDF file. You will have to take care and identify the primary key value for the report. This report ID is the value in the parameter key41.

Although the above button definition is for the ASP COM API, the same basic principle can be used for the .NET API.
  • I have a custom summary screen that I would like to be able to print as PDF.  I added the following code to my summary screen to add the print button.  However it does not open up a pdf with my screen to print.  This code is opening up a new window with the contents I want to print in it.  How can I make it so it opens the content as a pdf to print?

    var strDestination = "Adobe";

    var strSummaryReportButton = CRM.Button("Print", "print.gif", CRM.URL("CustomSummary.asp")+"&cust_customentityid="+Id+"&FlgNewWindow=True&Destination="+strDestination+"&PageSize=210x297&Orientation=Landscape", "", "", "EWARE_HELP")


  • The button example above prints the report to PDF because the Destination=Adobe in the url is a flag passed into the eWare dll along with the system action 1411.  This causes the report to be run serverside to generate the PDF file.

    Your button example that calls an ASP page will just call the page as normal.  You would have to call the page and with the ASP code identify that the output was to generate to PDF, and then send the HTML of the page to POP or another html to pdf conversion program on the server.  Once the pdf file is created on the server the ASP page could redirect to it and load that with in the browser.

  • Do you have any examples of code to accomplish that?

  • Danny

    I don't at the moment.  I will try and see what I can find out.

  • Jeff's article can be extended by using this library, i.e. a PDF converter using C# code, this works using the FOP, you might want to take a look at this , this is open source as well

  • Interesting!

  • Thanks Kannan,

    Can you please provide me an example of how I would incorporate this into my code to open the content as a pdf to print?


  • We have a customer with a problem whereby they export a report to PDF and the columns on the report come out pretty slim, and the data within the columns is being trimmed off the column edge, making it unreadable.

    Any ideas why this may be occurring or if/where I can configure column widths etc?

  • Ben

    I am afraid that I don't.  I think you will need to log a case.