Sometimes you need software that makes a certain process a bit easier – more streamlined. One example of such circumstances is printing documents to various formats, such as PDF, XLSs, and DOCx. Thankfully, there’s an easy to use, and free set of tools made by TIBCO Jaspersoft, that’ll help you do just that.
While executing an internal project using Oracle APEX technology, we were looking for a solution to streamline the processes of creating a document template and printing it to PDF, XLSx, DOCx formats. The goal was to get out of the currently used technology which, while great, only supports printing to the PDF format. The solution? The pl-jrxml2pdf packet that’s based on the work of Jaspersoft. The company has a history of creating free tools for designing and generating documents in various data formats.
Jaspersoft’s products proved to be the right choice. The experience gained in iReport Designer helped with the template design in Jaspersoft Studio, and the reporting process was assigned to the print server – JasperReports Server. Following this path, the task was accomplished and the user was able to print documents to the format of their choice.
JasperReports Server – introduction
JasperReports Server is a free and self-contained server that enables you to deliver key business information to your users in real-time, in a fixed data format, and in a variety of file formats. Reports can be executed and viewed within the application, exported to the desired output format, or scheduled for execution at a later time. JRS allows you to export files in popular formats such as PDF, CSV, DOCx, XLSx, RTF, ODT, PPTx.
JasperReports free server is a tool created for business analysts and IT professionals. It’s easy to install and configure, which is one of the reasons why you should get to know this solution better. In this part of the article, I will try to introduce the tool to all user groups. My purpose here is to discuss the possibilities offered by implementing this type of server in your company. The article was written based on version 6.1.0 of the software. It’s worth noting that the product is available under the AGPL license.
Jaspersoft and TIBCO – a little bit of history
The origins of Jaspersoft Corporation date back to 2001. The demand for reporting sparked the creation of the company’s first product, JasperReports Library – a library written in Java for integrating applications into this environment. The next step was to create a visual editor for creating report templates, so in 2002 Jaspersoft iReport Designer, a graphical editor for JasperReports Library was released. This product greatly simplified reporting.
In the meantime, the business intelligence market was growing, primarily due to the increasing availability of open-source tools. The company created JasperReports Server, a new product line that combined the advantages of JasperReports Library and iReport. Jaspersoft’s next step was to develop the Jaspersoft OLAP product, which led to the Jasper Business Intelligence Suite, integrating all previous Jaspersoft products.
Currently, the company offers tools for the Business Intelligence sector, but the brand is also involved in the OpenSource market, where it provides its solutions for free, under the name Community. In 2014, the company was bought by TIBCO for $185million and has since existed under the name TIBCO Jaspersoft.
What does the tool contain
JasperReports Server Community requires a Java application server and a database to create a repository in order to work properly. After downloading JRS, the installation process can install Tomcat server and PostgreSQL database automatically for us and the services will run depending on the Jasper server. It’s also possible to connect JRS to services already installed on the server. Moreover, while the free version supports the MySQL server, with the paid version you can also use commercial databases, for example, ORACLE Database, as a data repository.
JasperReports Server – what else is useful
The free version of JRS does not have a document template editor. For this purpose, you can use another Jaspersoft tool – Jaspersoft Studio.
Business information center
JasperReports Server allows integration with multiple data sources simultaneously. Data sources can be text files, relational and non-relational database environments, Java applications connected via JavaBean Datasource. JRS can be a centralized business information repository aggregating data from many other internal and external systems. In practice, a single JRS server connected to multiple data sources is sufficient. The retrieved information can be presented in a way that is readable by a regular user.
The server administrator can create accounts for users and assign them to selected groups – roles, granting rights to view, create and execute selected reports. There should also be no problem with the configuration of authentication via LDAP.
According to the producer, the commercial version of JRS additionally enables the user to create report templates by dragging and dropping from a web browser, just like in Jaspersoft Studio. Moreover, it gives you the options to create and view dashboards, and virtualize data from many remote systems to a single metadata string. That, in turn, allows for complex analyses without ETL or big data warehouses. With JRS you can create interactive table transformations (pivot), build a pivot table, charts, and real-time recalculations.
Detailed version comparison can be found here.
Where to use JasperReports Server
JRS allows you to connect to multiple data sources simultaneously within a single server instance. The server administrator can create connection sources to databases such as PostgreSQL, MySQL, Oracle DB, Microsoft SQL Server, Sybase, or IMB DB2. The commercial version additionally allows the use of Hadoop, Hibernate and much more.
Datasets available from the JasperReports server can be used to create user-readable reports prepared in a form that is clear to the user. Bar charts, column charts, grid charts, tables, lists, images and more can be used for such a presentation. One of the features is also a print server. Thanks to the support for REST Web Service API, JRS allows you to integrate the server with other applications. With this solution, the developer can use the service as a print server for documents and reports, printed to PDF or Excel files, for example.
Report template design
JasperReports Server can be a centralized repository of company information or a print server for more or less complex reports. As mentioned earlier, the commercial version of JRS allows you to design graphical documents directly in the web browser. In the free version, nothing is stopping you from using another free tool – Jaspersoft Studio. It offers an advantage of intuitive interface, which allows you to quickly create templates by using the drag and drop method. Users familiar with Jaspersoft products probably remember the previous generation of the tool called Jaspersoft iReport Designer, nowever that software’s official support ended in December 2015.
Integration with other applications – REST Web Service API
Both in the free and in the commercial version of JRS there is a web services layer. It allows you to easily connect any application to the JasperReports server, using a simple API. Web services are implemented using the REST (Representational State Transfer) Web Services API, which significantly extends the functionality of the server. As mentioned earlier, this allows integration with other applications. Developers with access to the server are able to create a document template (like a VAT invoice, for example), export such a template to JRS and connect it to their application using the available API. You can find more information on this functionality in the Jaspersoft documentation. Also, part of this article is devoted to the topic of integrating JasperReports Server with an Oracle APEX application.
Jaspersoft Studio tutorial – How to make your own VAT invoice template
Every enterprise needs documents and reports. In this part of the article, you can find information on how to use Jaspersoft Studio, a free program from TIBCO Jaspersoft, which is made available under the Eclipse license. It’s a tool that effectively simplifies the process of creating templates. In the downloadable content is a ready-to-import VAT invoice template, made available under the MIT license.
Prepare the required tools
Before we start working on the VAT invoice template, like any self-respecting craftsman, we’ll need some tools. First of all, you’ll need to download the free program Jaspersoft Studio. In the Release tab, you can find the current version – 6.17.0 (the article was written based on version 6.1.1.). The product is available for the most popular system environments – macOS, Linux, Windows.
In the next step, we need data. I provide a script for the Oracle Express Edition database (I worked with version 11g, the current one is 21c), which should be run according to the instructions included in the file. When you are done, you should have access to the data we will be working on later in the material. If you do not have the Oracle database on your computer, I encourage you to download and install the file from the Oracle website.
Connect JasperStudio to Oracle Database
If Jaspersoft Studio is installed and the Oracle database is configured, you can now create a connection to it in Jasper. To do this, start the program and go to the Repository Explorer tab, where you right-click on Data Adapters. From the cascade menu, choose Create Data Adapter.
In the new Data Adapter Wizard window, search for and click Database JDBC Connection, and proceed.
In the new window, complete the form as follows:
- Name: MyFirstJasperInvoice,
- JDBC Driver: oracle.jdbc.driver.OracleDriver,
- JDBC Url: jdbc:oracle:thin:@localhost:1521:xe, where after the “@” is the name or IP of the Oracle server, then the port and database SID,
- Username: invoice,
- Password: invoice.
In the next step, you need to provide the path to the JDBC driver for the Oracle database you currently use. To do this, go to the Driver Classpath tab and select the driver, which can be downloaded from the Oracle website.
After filling out the form you can test the connection by clicking the Test button. If you get a positive message, you can save the settings using the Finish button.
Learn your tools
After the first successes, it’s time to get better acquainted with the tool we work with. Jaspersoft Studio is a document template editor. The program runs on the Eclipse engine and is made available under the license of the same name. Officially, Jaspersoft Studio has become the successor of iReport Designer and is recommended for further work on documents. It is worth noting here that the latest update of the tool is not backward compatible and attempting to compile reports created in iReport Designer may fail. The same in the other direction.
The program should not cause major problems, especially for users who previously worked in Eclipse IDE. On the left side of the program, we have the already known Repository Explorer where we can create a connection to our data sources. Below, in the same window (Servers section), we can establish a connection to JasperReports Server, which was discussed in the previous section of the article. On the same page, in the next tab should be the Project Explorer. There you will find our new project, which we will create in a moment. On the right side of the application is Pallete and Composite Elements, a collection of useful components that we will be able to drag into our templates.
At the bottom of the application, you should see the Outline window, where you can find all the components that are on the template.
This should be enough to get you started. Please note that the application window configuration may differ from what the reader sees on his screen. If any of the windows in question are not visible, you can enable them in the Window -> Show view menu.
Create a template for your own VAT invoice
If you have correctly configured the connection to the Oracle database, just download the provided VAT invoice template and run the preview to see the sample. Additionally, I recommend reviewing the data structures that should already be installed on the Oracle database. The tables contain the invoice data that we are about to see on the PDF document.
Open and execute
You need to import the VAT invoice template design into Jaspersoft Studio. Just download the file, no need to unzip it. In Jaspersoft Studio, create a new project, and then from the cascade menu on it, select Import. In the new window, expand General and select Archive File.
In the new window select the downloaded JasperInvoice.zip file and then the project to which you want to import the files. Then just click Finish. If the package has been imported correctly, the new project files should appear in Project Explorer:
You can view the document by clicking Preview from the tabs under the report.
In the Preview window, select the appropriate data source by choosing the created connection from the drop-down list. See the screenshot below for details. When the program asks for the invoice_id parameter, enter the number “1” (if you have installed the Oracle database script provided in this article).
In the same window, Jaspersoft Studio allows us to preview our template in several versions. After expanding the list (see the screen above) we have access to many data formats such as HTML, PDF, DOCx, XLS, and many more. Just select one and the program will generate an invoice in the appropriate format. From the list below, you can select and preview a sample export to different types:
- Excel (XLSx),
- Word (DOCx).
Sample invoice can be downloaded here -> invoice.pdf.
Jaspersoft Studio software gives you the ability to dynamically and quickly create document templates. Just create a template once and then use it to generate many different documents. All template edits can be implemented instantly and the time saved can be invested in other tasks.
Integrating Jaspersoft Studio with JasperReports Server
We have already become familiar with Jaspersoft Studio, we have a document template ready and we can import the result of our work to the JasperReports Server. Now the questions arise: how to do this? Is there a way to do it easily? The answer is yes. The tool which we used to build the template has one more interesting feature – it allows to export files to the repository server.
In this part of the article, the reader will learn the easiest way to integrate your Jaspersoft Studio report with JasperReports Server.
To work, you need JasperReports Server and Jaspersoft Studio. I assume that the server, as well as the application, are installed on the same computer you are working on (localhost). If you haven’t already done so, I encourage you to click on the links, download and install the tools.
Connecting JasperReports Server
If you have already read the previous part of the article, you know how to make a simple invoice template, and you should have no problem finding the Repository Explorer tab. With a standard installation of Jaspersoft Studio, the tab is located on the left side.
In that tab click on Servers and select Create JasperReports Server Connection from the cascading menu.
In the new window, complete the form according to the scheme:
- Name: localhost JasperServer,
- URL: http://localhost:port/jasperserver/, where we replace the port with our own port on which JasperReports Server listens,
- User: jasperadmin (the default value),
- Password: jasperadmin (the default value).
And click Finish to proceed.
After adding the server and expanding its details, we get a set of folders just like in the JasperReports Server application. You can expand each folder to learn more about it.
Integration – publication
Go to the Project Explorer tab and click on the invoice template, the same one you can download from the previous part of the article. Now we find the button highlighted on the screen below.
In the new window, click Reports or another directory where you want to store the invoice template. If you need a different or new directory, you can create one in JasperReports Server at http://localhost:port/jasperserver.
We move on by clicking Next. In the next window, we upload template resources – that is, files such as the invoice logo or the invoice input parameter, which is also a resource.
In the next step, we click Next yet again, and we select the data source (Select Data Source from Repository and expand Data Sources). Select the connection to the Oracle database server. Note, if you do not have a connection to the Oracle database configured in your JasperReports Server application, you should do so now and return to publish the template again. If you need information on how to create a new connection in JasperReports Server, I encourage you to check out the article on the Jaspersoft website.
After selecting the appropriate server, you can complete the process by clicking Finish.
The invoice template has been uploaded to the repository. Now you can test the report in the JasperReports Server application. In this case, we go to http://localhost:port/jasperserver/, log in as jasperadmin (password: jasperadmin), expand Reports (or another previously indicated directory), and click on the template name (in my case invoice).
In the window that appears, as a parameter invoice_id put the number “1” and click OK. As a result, you will see on the screen an HTML document for the invoice with ID#1.
As you can see, the process of publishing a new or modified document template is simple and intuitive. For the most part, publishing a template should not cause you any problems. Except for publishing projects that contain subreports that Jaspersoft Studio does not want to send. In this situation, we can use the List element, which has its own data source. Another solution is to edit the template on the JasperReports Server page.
As you can see, Jaspersoft’s software is a powerful set of tools you can use to create document templates, and print them to various popular formats. You can use these solutions with Oracle DB technology, and applications based on Oracle APEX (I’ll cover the latter topic in the second part of the article). You can also download Jaspersoft’s programs for free, and that choice doesn’t require a compromise in terms of security or stability. What more can you reasonably expect from software for this specific purpose? Not much, honestly – it’s a very good alternative to commercial solutions. For more information on the technology you can also check out my other article: TIBCO Jaspersoft software tutorial: Integrating JasperReports Server with an application in Oracle APEX.
Are you looking for Jaspersoft experts?
Jaspersoft Studio is just a tip of the iceberg – Pretius knows many different technologies inside and out. We have a great deal of experience with big projects for companies operating in different industries. If you need software developers, drop us a line at firstname.lastname@example.org (or use the contact form below). We’ll get back to you in 48 hours and tell you how we can help.