How to print a report in Java? - java

I came from C#.
.NET offers a reporting tool (Crystal Report) to print reports.
I'm using a JTable populated by a source.
How do I print the records from the JTable without using jTable.print()?
How can I control the layouting?
Is the only way to print reports in Java is to use java.awt.print and javax.print?

BIRT allows you to handle data from POJO (Plain Old Java Object) datasource, consult BIRT developer channel on youtube, there is a tutorial about that.

Dynamicreports is suitable for the purpose you had mentioned. It is build on top of Jasperreports and it is simpler to use than Jasper reports.
http://www.dynamicreports.org/
You can find the examples here: http://www.dynamicreports.org/examples/examples-overview

Related

Birt report with hibernate

Hi I'm trying to find a way to create birt reports with datasets based on a hibernate data source. However, I downloaded eclipse report designer and related plugins, but can't seem to find an option for hibernate data source. Was this functionality taken out?
I have gone through a couple of links and either they are old libraries or the integration is done via seam. The only reasonable examples i found are using Scripted data source to access hibernate POJOs. But nothing on how to access hibernate entities directly from the report at least in the latest versions of birt.
Or is there something that I'm missing?
You can check my approach based on POJO data source (without using scripting data source). I finally found some time today to describe it here.

How to create Report from DB information in PDF format without using jasper

I want to create reports in PDF using the data available in database. I want to do some data manipulation and use the charts and details to be shown in pdf to the user.Suppose say there are 2 columns in DB a and b . I want to show in the PDF, the value of a and b and the addition of a and b. What i can use to generate this pdf report?
I thought of using jasper, but i donot want to use it. Instead is there any other logic in java that can help to solve this problem. Please suggest with examples.
Thanks
Birt is a tool that can be used to generate all sorts of reports. There are plugins for Eclipse that you can use to help you get going and you can definitely add logic in Java. It can output your report in multiple formats including PDF, HTML, and I believe even Word docs.
If you've used Eclipse before you should be able to figure out the basics, but it can get as complicated as you want. In its simplest form you attach data sources (such as a database with a JDBC connection) and you structure your joins and layout fields onto a form. You can even tie it into a Java EE container if needed.
There are examples on their website and it has a rather large community to help with questions.

Configuring & Generating BIRT Reports Dynamically

From watching the 2-part YouTube videos and perusing the BIRT manual, my understanding of it is the the worflow goes something like this:
Create a new Report in Eclipse
Use the BIRT Report Designer (Eclipse plug-in) to design a report
Populate the report with Data Sources (JDBC drivers & databases) and Data Sets (specific tables)
Generate/export/print the report
As cool as this tool seems to be, I cannot find any documentation that leads me to believe that this is a Java tool and not an Eclipse-only tool (meaning, it has a Java API and can interact with Java apps, as opposed to a pure Eclipe plug-in which requires manual/human interaction from the Eclipse IDE.
Specifically, I want to confirm that BIRT either can or cannot do the following:
Configure a report (layout, UI widget placement, data sources/sets, etc.) programmatically; i.e. in the same way that JasperReport API has the iReport designer that generates JRXML, is the same true for BIRT?
Kick off a report "generation" through a Java API whereby data gets read-in realtime and populates the report and the report can be sent out or stored on a file system
Create HTML and PDF versions of the same report
Answers to your questions:
Yes. BIRT may not be as powerful as JasperReports, but it can achieve most of the common needs.
BIRT designer generates a .rptdesign file similar to JRXML in JasperReports.
About your question: almost everything is possible to achieve programmatically in BIRT. BIRT Report Engine APIs is the best source for you to get started with all the functionalities you have mentioned. It has good examples given for every functionality.
Not sure. BIRT usually fetches pre-saved data from DB and generates the report. You could though see the real time data representation (in the form of a flash chart may be) with the help of some external libraries (See if this thread and this example helps). But I am not aware of a direct way of converting the real time data to PDF/HTML report. You will have to find some hack(s).
Yes of course. Refer the APIs. To be specific, irendertask.
Sources to get more information/answers:
There are several example reports given on the website. A quick glance through them might give you more insights.
For discussions and troubleshooting, refer eclipse community forum and BIRTExchange (heavily used by BIRT users).
BIRT: A Field Guide to Reporting is an excellent book. I've used it myself from time to time.
I can confirm that the two BIRT components you are interested in using (BIRT Design Engine and Report Engine) will work in a pure-Java context and are deployable without Eclipse. I have deployed BIRT reports to run out of standalone Tomcat servers as well as Pentaho BI Server, and have exercised report definitions at the command line using shell scripts (no Eclipse involved).
Answers to your questions:
Configure a report programmatically: use the Design Engine API. I am not familiar with the Jasper Reports API so cannot comment on whether the BIRT method is similar, but the example code provides a good illustration. In particular, note lines 120-133 which add and manipulate widgets in the report, and how line 136 calls saveAs to save the report design file.
Generate a report in realtime: use the Report Engine. The sample code for the IRunAndRenderTask may be the most useful for you at first, but the engine has the ability to separate the data processing (extract and aggregate) of the report from the rendering and paging. I believe the examples focus on running reports from a Servlet, but it is easy to extract that logic from the servlet container logic.
Create both HTML and PDF versions: easily handled in the Report Engine via the IRenderTask. Once you've been through all the other setup work, changing the output format to produce PDF vs HTML is something of a joy. In my experience, it just works.
I found it useful to start out with a very simple Java class (adapted from the very old code here) to run a test report, called from the command line.
you can use the report engine API to configure reports:
http://www.eclipse.org/birt/phoenix/deploy/reportEngineAPI.php#ireportrunnable
You can create HTML or PDF versions of a report by setting a variable in the url to generate the report or if using the report engine programmatically:
http://www.eclipse.org/birt/phoenix/deploy/reportEngineAPI.php#irendertask
We use Eclipse to build and design reports. The report engine is deployed as part of a reports_war, the war has its own connection to the database. Our Java based web application uses urls to interact with the report templates (variables are set in the urls).
The BIRT Exchange is a good place for more information
There is not much difference between Birt and jasper as designing point of view except birt have eclipse plugin.
1)yes,you can configure it by java program or methods.
2)yes,this is possible.
3)yes again for export your report in different formats is easy for birt report by java
BIRT is a good and easy tool fro report generating.
you can design your pages in BIRT.
-
Create datasets and can pass the values from your web pages to your BIRT design using jsp tag lib.
BIRT fulfills all your requirement. Its so easy to use. first i use jasper, then tried crystal atlast Birt gies the output.
tag lib
i refer this link to view BIRTVIEWVER in my web page. PDF creation is so perfect in BIRT. You can generate PDF, DOC, HTML also.
you can pass values to your birt . while creating dataset there is option for passing params.
to do all this you have to install BIRTREPORT inyour eclipse BIRT Report designer

Is it possible to fill templates (.xls, .pdf, ppt) with Birt or alternatives?

is it possible to fill a predefined template file via birt reporting?
.xls for exmaple: The template should have defined the column headers (nicly formatted) and some other stuff like the date of creation, the user, some legal notice, ...
.pdf on the other hand should define id-fields that are to be filled with data
.ppt as the last and may be trickiest one should ideally be also be useable as .pdf but as far as I know .ppt itself does not provide IDs for its fields and therefore a workaround must be used to identify the places to be filled
Are there alternatives to birt that might be able to do that?
I'm very curious about the answers :-)
Thanks a lot!
Templater supports docx and xlsx. From there we are generating PDFs using LibreOffice.
Being author of the tool, I highly recommend it :)
There are plenty of examples on site if you are interested.
It could be very challenging to hit a predifined Excle format with the native BIRT Excel emitter, there are several after market Excel emitters that might help you get there.
The easier way is to set up your BIRT report to export with the format you want, then save report and use it as foundation for recreating the next report. You can use grids, and master pages to get just the layout you want, then plug in report pieces.
You can also use the library to save grids, tables & data sets that you use over and over.
The Spudsoft XLS Emitter for BIRT (which is builtin with BIRT 4.3.1) supports this for XLS.
We are using this feature and it works like a charm.
However, BIRT does not support "filling" doc or ppt docs.
Templating engines usually have difficulties to support master-detail (or master-detail-detail) relationships. This is due to the somewhat stupid implementation of tables in MS Word.

Create PDFs from multipage forms in WebObjects

I would like to automatically generate PDF documents from WebObjects based on mulitpage forms. Assuming I have a class which can assemble the related forms (java/wod files) is there a good way to then parse the individual forms into a PDF instead of going to the screen?
The canonical response when asked about PDFs from WebObjects has generally been ReportMill. It's a PDF document generating framework that works a lot like WebObjects, and includes its own graphical PDF builder tool similar to WebObjects Builder and Interface Builder. You can bind elements in your generated PDFs to dynamic data in your application just as you would for a WOComponent.
They have couple of tutorial videos on the ReportMill product page that should give you an idea of how the tool works. It'll probably be a lot easier than trying to work with FOP programmatically.
I'm not familiar with WebObjects, but I see you have java listed in there.
iText is a java api for building pdfs. If you can access a java api from WebObjects you should be able to build pdfs that way.
ERPDFWrapper component in Project Wonder: Site link
ScArcher2>>
I have looked into different routes for creating PDFs on the fly including FOP and a few Java libraries. I think what I am really asking is if anyone has already done this in the WebObjects framework. My hope is that someone familiar with WebObjects might have done this already and have some insight that would save me some time.
You can use ReportMill or Jasper Reports. Compared with ReportMill Jasper Reports is Free but requires learning huge library. You can use IReport or Jasper Assistant eclipse plugin(If you are using WOLips) for building report templates. My experiance both are good.
Jasper Reports support have been added to Project Wonder a week ago :
Site Link Video
A talk about that new framework was done at WOWODC 2010, and it was recorded. Check wocommunity.org and the mailing list about that in October.

Categories