Pentaho Tools :

Pentaho C-Tools(CDE,CDF,CDA),Pentaho CE & EE Server,OLAP-Cubes,Analysis using Pivot4J, Saiku Analytics, Saiku Reporting, Ad-hoc Reporting using Interactive Reporting Tool,Dashboards,Reports using PRD, PDD,Data Integration using Kettle ETL,Data Mining usign WEKA,Integration of Servers with Databases,Mobile/iPad compatible Dashboards using Bootstrap Css,Drilldown dashboards,Interactive Dashboards

Tuesday, 24 December 2013

Exporting CDE dashboard to pdf - the usage of PRD for CDE

Hello guys...

Exporting chart components as images to pdf in pentaho CDE - Simple Example

Here is the functionality of exporting CDE chart components to pdf file using PRD.

Environment :
C-Tools : V13.09
Pentaho Server : 4.8
Database : foodmart (jasperserver default database)
Web browser : Mozilla Firefox

NOTE : This post is specific to export chart component(s) to pdf but not the table component you are seeing in the images in this post.

What you can learn from this example ?
1) Make use of button component for exporting dashboard charts to PDF.
2) What is CGG component ? How you can make use of CGG component in exporting charts as images to PDF ?
3) How you can use PRD(.prpt) tool to export the images to PDF.
4) How to pass parameters in the URL when you export the dashboard charts as images in pdf file.

Example :
1) Lay out section 
* Design and develop your dashboard as per your requirement.
* Find the image below
2) Data sources section
(Talking about chart only)

* Give database connections and write a simple query which gives meaning full visualization.
* For example:
SELECT fname,customer_region_id  FROM customer LIMIT 6


3) Components section

i) Take button component from others give place holder in layout section as shown in first image
ii) Give:
Name : ExportToPDF
Label: ExportToPDF
HtmlObject: ExportPDF
Expression :
Write below code:
function sendParameter(scene){
       var url='http://localhost:8085/pentaho/content/reporting/reportviewer/report.html?solution=CDEExploring&path=%2FDevelopement%2FExporting&name=ExportPDF.prpt&locale=en_US';        
       window.location=url
}
Code image is shown below.  


We'll come to know from where we are taking the code above seen in image.

Here PRD(Pentaho Report Designer) comes into picture to export the CDE dashboard charts to pdf or any other format.

Below steps are the work around  with CGG(Community Graphics Generator) & PRD

For CGG complete reference find Pedro's blog here
From web details http://www.webdetails.pt/ctools/cgg.html

Steps :
1) Preview your dashboard
2) Press shift+G .. you will find pop up of CGG and URL generated for the charts in your dashboard.
    i.e., once you click shift+G , pentaho Engine generates .js files related to that particular chart(s).
3) Take that URL and paste in any web browser address bar (Mozilla is preferable).
    it'll generate the images of that particular .js file(i.e., for that particular URL).
4) Your browser directly doesn't know from where the data is coming.. so you need to provide the user name and password of your pentaho(for instance: if you run pentaho on joe and password for 4.8 BA server you need to give these details)
Example:

http://localhost:8085/pentaho/content/cgg/Draw?script=/CDEExploring/Developement/Exporting/DashboardExport_BarChart.js&outputType=png&userid=joe&password=password

Note that if your chart in the dashboard is using any parameter you need to pass them by adding to the url
Syntax for adding parameters : &param_name=parameter_value  
Example : &param_country=USA

5) Now, open PRD and save the .prpt file

6) Drag and drop image to "Report Header"(Preferable band) and double click on it. Give the same URL for that image, also adjust height ,width of the image. You will find the same image that you seen in web browser here in PRD image component.(If you wont find you missed some where in the development).

7) Now publish the .prpt file to Pentaho BA server.. [the folder which you are keeping your dashboards is preferable to publish your report]
    [the same way you publish schema]

8) See the preview of the report.. there you can export generated output to different formats.. lets say pdf, xlx, html and etc.

9) After seeing the preview of the .prpt file, open the same  using" Open in New window" which generates the URL for that..

10) Give the same URL in Button component " Export" property which you can find in step 3(Components section).

That's it.. you have done with exporting chats of dashboard to pdf and other formats..


Find the images below for the same
step 1 & 2  image:

step 3 and 4 image:


Step 5 and 6 image:


Step 7 images:


Step 10 output:

Reference :
http://www.ambientbi.co.uk/?p=357

Hoping that this tutorial is helpful also hoping that there will be direct export functionality in pentaho CDE in upcoming releases from pentaho(Pedro).

Suggestions/Improvement of post are welcome in comments box :)