`

Exporting Pentaho CDE Dashboards to PDF

 
阅读更多

Step 1: Configure Sparkl

Sparkl is a plugin creator instrument that sits on 2 major cornerstones of Pentaho: Ctools and PDI, aiming to leverage as much as possible of our existing stack. Dashboards are used for the front-end part and PDI (named Endpoints in sparkl) are used for the back-end logic.

In order to export our dashboards to PDF we only need the endpoint part but we’ll build a small dashboard so we can test the endpoint.

First of all you must install Sparkl using Pentaho Marketplace. Be sure to install dependencies: CDF, CDA, CDE and CGG. It’s recommended to have installed same versions of CTools (14.07.29 STABLE in my case)

Pentaho Marketplace

Restart your BI Server and access Sparkl using the menu Tools as shown in image below.

Sparkl menu

Now you’ll see the initial Sparkl desktop with a default aplication:

Sparkl default desktop

Step 2: Create Sparkl Aplication

Now it’s time to create the aplication! Let’s click on “Add” button and fill the Aplication Description.

Aplication About Description

Select “Elements” tab and click in “Add New Element”. Set a name for the element, select “Kettle Endpoint” as element type and “Clean Job” in template. Now click on “+” button to add it to our application.

Sparkl Kettle Element

You can check your brand new Job in the directory:

"biserver"/pentaho-solutions/system/"app_name"/endpoints/kettle/"element".kjb

Step 3: Edit Kettle Job

Open the Job with Spoon and you’ll see a very simple Job with only “Start” and “Success” steps. Your final Job will look as the following image:

PDF Export Main Job

Our Kettle endpoint will use 3 variables in order to generate PDF file:

  1. URL to render in PDF
  2. Pentaho BIServer directory
  3. Name of PDF file generated

We’re going to call the endpoint using these params so we need to set them in the Job. This is the purpose of the first step, a transformation with variables initialization:

Job variables initialization

Next step is a simple Javascript evaluation to know if our installation is Linux or Windows, because we’re going to use a library call and the script depends on the platform. The code needed to know if the installation is based on linux or windows is:

is_windows

If true then we’re going to use a branch based on Windows scripting and if false then we’ll use a Linux script.

Next step is where “magic” happens. We’re going to use PhantomJS to render our PDF file. The step execute a shell script with following code:

${PENTAHO_FOLDER}\tomcat\webapps\pentaho\phantomjs-lib\phantomjs.exe rasterize.js "${URL_PARAMS}" ${FILE_NAME} A4
(in case of Windows branch)

./phantomjs rasterize.js "${URL_PARAMS}" ${FILE_NAME} A4
(in case of Linux branch)

We must to set Working Directory in the step to

${PENTAHO_FOLDER}\tomcat\webapps\pentaho\phantomjs-lib
(in case of Windows)

${PENTAHO_FOLDER}/tomcat/webapps/pentaho/phantomjs-lib
(in case of Linux)

In last step (PDFFile Transformation) we need to copy our generated PDF file to result.

Job Copy File To Result

In “Get File Name” step we use following selected file:

${PENTAHO_FOLDER}\tomcat\webapps\pentaho\phantomjs-lib\${FILE_NAME}

and then add a step to copy files to result.

Step 4: Finishing Kettle Job

Before we can test the Job we must set a couple of things. First, set Parameters of the Job (double click on empty space in spoon) to force Kettle output to ResultFiles. Remove # in cpk.response.kettleOutput parameter and set the default value to ResultFiles.

The second thing to do is to copy PhantomJS library in Pentaho folder: tomcat/webapps/pentaho/phantomjs-lib.
Download PhantomJS in: http://phantomjs.org/download.html

You need phantomjs.exe, phantomjs and rasterize.js files. checkout files permissions after copy them

Step 4: Testing Kettle Job

Go to your Pentaho Data Integration folder and launch this:

./kitchen.sh -file:/opt/pentaho/biserver-ce/pentaho-solutions/system/pdfExport/endpoints/kettle/pdfJob.kjb -param:urlParamsParameter=http://pentaho.com -param:pentahoParamsParameter=/opt/pentaho/biserver-ce -param:fileParamsParameter=pentaho-landing.pdf

This command will launch our ETL job and it’ll render “pentaho.com” landing page in “pentaho-landing.pdf” file.

If something goes wrong check the log, common errors are typos or file permissions.

Pentaho Landing page in PDF

Step 5: Exporting your Dashboard

I’ve developed a Dashboard for a project (don’t worry about NDA. It’s dummy data) and the client want to export it to PDF.
I have the sparkl app up & running but how can I call it from CDE?? Well, there is several ways to do that, best way is using “datasource” property in Button Component that execute endpoint. You have Success and Failure callbacks properties to add functions to handle function returns.

Pentaho Button Component

Other way is to use Expression property to build the call to our endpoint. All we need to do is invoke endpoint passing params in query:

http://biserver-ip:8080/pentaho/plugin/pdfExport/api/pdfJob&paramurlParamsParameter=http://pentaho.com&paramfileParamsParameter=pentaho-landing.pdf&parampentahoParamsParameter=/opt/pentaho/biserver-ce
same result that previous kitchen call

So we write that function in Expression property in Button Component:

` function f() {

var newURL = “http://” + window.location.host + Dashboards.getWebAppPath(); var url = newURL + ‘/plugin/pdfExport/api/pdfJob?bypassCache=true’; url += ‘&paramurlParamsParameter=’ + encodeURIComponent(urlParamsParameter); url += ‘&paramfileParamsParameter=’ + fileParamsParameter; url += ‘&parampentahoParamsParameter=’ + pentahoParamsParameter;

window.open(url,‘PDF Export’,‘toolbar=0,resizable=1,location=0,status=0’);

}`

‘urlParamsParameter’, ‘fileParamsParameter’ and ‘pentahoParamsParameter’ are Simple Parameters where you can set your values in order to export whatever you want.

Usually you want to set ‘pentahoParamsParameter’ to your biserver-ce installation folder, ‘fileParamsParameter’ to a fixed file name and ‘urlParamsParameter’ to your Dashboard URL. How can you get your Dashboard URL? easy… double click on Tab to open on a new window and copy URL to the parameter.

Opening Dashboard in new Window

Copy Dashboard URL

References:
1. http://www.osbi.fr/exporter-en-pdf-des-dashboards-pentaho-cde-avec-phantomjs/
2. http://diethardsteiner.blogspot.com.es/2014/02/sparkl-create-your-own-app-for-pentaho.html
3. http://fcorti.com/pentaho-sparkl/kettle-endpoint-sparkl-pentaho/

Happy coding!

 

 

 

 

转载: http://joshid.github.io/blog/2014/10/08/pentaho-pdf-export/

  • 大小: 15.4 KB
  • 大小: 21.1 KB
  • 大小: 16.1 KB
  • 大小: 119.3 KB
  • 大小: 260.5 KB
  • 大小: 95.1 KB
  • 大小: 54.6 KB
  • 大小: 7.9 KB
  • 大小: 69.5 KB
  • 大小: 213 KB
  • 大小: 597.4 KB
  • 大小: 248.3 KB
分享到:
评论

相关推荐

    PDF_Editor

    9. Eliminated erroneous messages when exporting certain PDF files. 10. Fixed a refresh issue while zooming out on some certain PDF files. 11. Fixed a preview display problem when exporting pages ...

    Monetizing Machine Learning--2018

    Create rich web dashboards to handle complex real-time user input with JavaScript and Ajax to yield interactive and tailored content Create dashboards with paywalls to offer subscription-based ...

    编辑任意PDF文件

    The View Annotations function enables users to view the annotations added to the PDF document. Users are able to easily check all the comments by checking the option to “Show Comments” on the status...

    FastReport Professtional 5.4.6 full source.rar

    - Fixed export to PDF for FCharSpacing <> 0 and HAlign = haBlock - Fixed exporting of Unicode characters to ODF for non-Unicode IDE - Fixed exporting of text with empty lines at the end to XLSX ...

    Foxit PDF Editor.zip

    pdf修改 Fixed a crash issue which occurs when closing any palette of the five image toolbars within the Image Editor window, or closing the ...9. Eliminated erroneous messages when exporting certain PDF

    Spire.PDF API

    Spire.PDF API 为Spire.PDF 帮助文档,详细罗列Spire.PDF 控件提供的各种类,接口以及属性。对于如何了解和使用产品,有很好的指导意义。

    highchars图表exporting.js

    highchars图表用到的基础js,还有其他js需要用到的会一同上传

    Tableau.Creating.Interactive.Data.Visualizations

    Use data visualization principles to help you to design dashboards that enlighten and support business decisions Integrate your data to provide mashed-up dashboards Connect to various data sources and...

    EXP-00091 Exporting questionable statistics

    NULL 博文链接:https://xujq.iteye.com/blog/1714222

    A Student's Guide to Python for Physical Modeling 无水印pdf 0分

    You will learn how to install an open-source Python programming environment and use it to accomplish many common scientific computing tasks: importing, exporting, and visualizing data; numerical ...

    西门子_Exporting archived Data from WinCC into a .csv-File.pdf

    西门子_Exporting archived Data from WinCC into a .csv-Filepdf,

    Monetizing Machine Learning

    Create rich web dashboards to handle complex real-time user input with JavaScript and Ajax to yield interactive and tailored content Create dashboards with paywalls to offer subscription-based access ...

    exporting-a

    type 导出文件的类型,可以是 'image/png'、'image/jpeg'、'application/pdf' 或 'image/svg+xml' 中的一个 filename 导出文件名,默认是 “Chart” scale 基于原始 SVG 的缩放比例,当指定了 width 参数时,该参数...

    Hands-On Data Visualization with Bokeh pdf

    Learn how to create interactive and visually aesthetic plots using the Bokeh package in Python Key Features A step by step approach to creating interactive plots with Bokeh Go from nstallation all ...

    Typora soft for Word exporting feature

    Typora soft for Word exporting feature; pandoc exe is used to help Typora to output a word document

    Aspose.Cells API 中文版文档

    Aspose.Cells 最新并且非常详细的API开发文档。... It also allows exporting Excel files to PDF, XPS, HTML, MHTML, Plain Text and popular image formats including TIFF, JPG, PNG, BMP and SVG.

    Excel Importing & Exporting Text Data (Data Analysis With Excel) (2016)

    Excel Importing & Exporting Text Data ---Quickly Turn Raw Data Into Excel Tables, By Scott Hartshorn, epub格式版。

    Hands-On Start to Wolfram Mathematica.pdf

    Chapter 19 Importing and Exporting Data Chapter 20 Data Filtering and Manipulation Chapter 21 Working with Curated Data Chapter 22 Using Wolfram|Alpha Data in Mathematica Chapter 23 Statistical ...

    Active Directory Cookbook, 3rd Edition.pdf

    Covers the basics of searching Active Directory: creating, modifying, and deleting objects, using LDAP controls, and importing and exporting data using LDAP Data Interchange Format (LDIF) and comma-...

    highcharts.js;draggable-legend.js;exporting.js,

    网上下载的 highcharts.js;draggable-legend.js;exporting.js,

Global site tag (gtag.js) - Google Analytics