Jump to content
We've recently updated our Privacy Statement, available here ×

Creating TXT Format reports using Jasper reports


e_kannan

Recommended Posts

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Hi,

 

You did not say which exporter you have used to obtain this output. There is one text exporter in JR and iReport has also one, which is different.

Please check the /demo/samples/text sample provided with the JR project package. You'll note that in order to obtain good results in exporting to text, you have to make the reports in a certain way and pay attention to element size and fonts.

You need to use a fixed font size and use measurments that would fit when transformed into a pure text matrix.

It is likely that the blank likes you see come from a imperfect division between line height and character height.

 

I hope this helps.

Teodor

 

Link to comment
Share on other sites

 Hai,

I am using the same JRTextExporter in my source like 

 

JRTextExporter exporter = new JRTextExporter(); 

exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);

exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, strOutputFileName );

exporter.setParameter(JRTextExporterParameter.CHARACTER_WIDTH, new Integer(<WIDTH>));

exporter.setParameter(JRTextExporterParameter.CHARACTER_HEIGHT, new Integer(<HEIGHT>));

exporter.setParameter(JRTextExporterParameter.BETWEEN_PAGES_TEXT, "");

exporter.exportReport();

like the jasper reports /demo/samples/text/TextApp.java. 

But the bolded width & height is varying based on the report layout(Page Width & Page Height). I have got some tip to set the charwidth & charheight based on the following formula..

charwidth = page width / total no. of chars in a row    & charheight = page height / total no. of chars in a column                            

But there is no specific method is suggested by Jasper for calculating charwidth & char height.. So, Finally i have got the output in a plain text format. But Still, i got the blank lines every 10 lines.. How to avoid that blank lines?

 

Thanks
Kannan.

 

 

Link to comment
Share on other sites

Hi,

 

Tracking this issue down would take a lot of time and effort and personnally I have little desire to do so because the text exporter in JasperReports is the last piece of functionality we would want to improve or fix. I was always reluctant to have a pure text exporter in JasperReports because to me it does not make too much sense to use an intensive graphic tool such as JasperReports to produce non-graphic content such as pure text files.

If you do so, you are not using the proper tool for the job. There are other text oriented templating libraries such as Velocity, which would better suit these requirements.

 

So what I'm saying is that even there is a bug in the text exporter, the chances of having it fixed by the JR team are low at this moment, as it is not one of our priorities. You could either try to find the bug yourself and contribute back to the project with a patch, or, if you still want to have it fixed by us, maybe becoming a Jaspersoft customer would enable you to have this issue escalated and then we would obliged by contract to provide a solution or a fix to you, like we do for all our paying customers.

 

Thank you,

Teodor

 

Link to comment
Share on other sites

Hai teodor,

 

Thanks for your reply. We need to deliver some reports which has more pages(in thousands) and the customer uses line printer(prints very very fast when compared to inkjet/laser type printer) to print txt format reports. So, we decided to deliver few reports in txt format. Thats why i am asking the line space question.

Anyway, except the graphical elements(including that line, shapes etc)& the blank lines, remaining rendering correctly.

 

If any support is needed, we will contact you. Thanks a lot.

 

Thanks,

Kannan.

 

Link to comment
Share on other sites

  • 3 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...