PDF reports in Python web applications — Part 2: Browser-based report template design
In the first part of this article series, PDF reports in Python web applications — Part 1: Server side report generation, I explained the server side reasons why we decided to develop our own reporting framework. In this arcticle I’ll concentrate on the client side — in particular on report template design, testing and deploying report templates. I’ll again focus on differences between Jaspersoft Studio (I refer to it as Jasper or Jasper Client in this article) and our own report framework ReportBro.
Jasper uses a client application (based on Eclipse and therefore requires Java Runtime Environment JRE) which exists for most operating systems and has to be installed locally. After starting the application you should be ready to create new report templates.
2. Report Designer functionality
Jasper is a very powerful and feature rich tool. Jasper Client supports charts, sub-reports and many complex elements. While its capabilities are extensive it sometimes makes creating simple reports more complicated than it should be. Data queries are an integral part of most reports in Jasper and hence a deep understanding and knowledge of SQL is essential. But even for some simple tasks, like printing the current page in the footer (page x/y), you need to be aware of different types of expression evaluation. For us, and probably most Jasper novices, this was quite difficult to understand and get right in the beginning.
ReportBro, on the other hand, is optimized for simple reports, i.e. displaying data (text, tabular data or images) exactly as defined on a layout template. All parameters are passed to the report directly and therefore ReportBro doesn’t require SQL (or other query language) knowledge to create a report. In contrary, using the same data requests in the underlying web application and for report generation eliminates the risk of potential inconsistencies between displayed data on the screen and the printed report.
ReportBro allows to easily and quickly design reports with a perfect layout. Printing the current page in the footer is as simple as inserting predefined variables for current page and total page count. Even for generating Excel outputs no additional configuration is needed. Because ReportBro has a very clear structure it’s easy to learn.
3. Creating a report
A controller in our web application is responsible for creating reports. In case of Jasper the controller performs a web request to Jasper Server which is not accessible from outside. In the controller we also check if the user is authorized to generate a designated report. In case of downloading multiple reports, e.g. in a merged pdf or as a zip-file, these various requests cause an overhead and result in poor performance.
We do not have such an overhead with ReportBro as we can directly
generate all our reports in the Python web application controller.
Therefore report generation is noticeable faster in our setup.
4. Test data and testing reports
Test data can be specified as part of the report in both solutions. Usually in Jasper you’ll connect to a database, so you’ll need to have a data source available as well for testing purposes. This makes testing much more difficult, especially when using a different Jasper server and database for local testing.
In ReportBro all test data is contained within the report definition. Test data for parameters like texts or lists of other data can be defined. This simplifies testing a lot because a report preview (using test data of the report itself) can be generated and viewed anywhere since it does not have any external dependencies like a data source.
5. Updating reports
To update an existing report in Jasper you need to open the report in the client application and upload it to the server. This can be done within the Jasper Client once the server connection is initially configured. Because we have different reports for different customers this task is not only tedious but also error prone. That’s why we created a script to automate the report upload, along with specific tasks to create all report units and reports for a new customer. However, this still doesn’t help with report versioning which has to be done directly on the Japser server.
Due to ReportBro Designer being integrated seamlessly in the web application all we have to do is to update the report within the application. We even developed versioned reports in our application — which is fairly simple as the report template is a JSON object that can be stored inside our application database. This allows us to easily test and switch between different versions of a report.
6. Report updates by application users
Our goal has always been to allow our application users to perform some minor report changes themselves. E.g. sometimes they simply want to modify the layout, change text formatting or add static text to a template.
With Jasper this is basically impossible because the user would need technical know-how not only to get the current report file from the server and upload changes but also to actually do simple updates without taking the risk of corrupting the template itself. While our clients are generally apt in working with web applications they usually lack that particular kind of know-how.
Being part of the web application makes ReportBro directly available to users. ReportBro has a built-in admin mode functionality which allows disabling all parameter fields for users while still being able to test them. Hence, predefined parameters that are filled during report generation and thus should not be altered by a user of the designer are untroubled by layout modifications. This enables our application users to perform basic report layout changes themselves and as a consequence it means less work for us.
Want to find out more? See and try the demos: https://www.reportbro.com