• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

looking for an api/library like mail merge

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

(P.S.: I didn't know where to put this question, so I wrote it here. Sorry, if this is the wrong place.)

Could someone direct me to an api/library that has similar functionality like a mail merge?

I want to use this api to do something like the MS Word mail merge through my program. The user program will send the data and the x,y co-ordinates ( this can be any number of time) where the data is to be displayed in the final printed document. The api should output a text buffer (string buffer), which my program can use to print on a form. Also, the user program needs to be able to set the header and footer (both optional), but only once, and the api should be able to add them to the text buffer as needed so that when the content in the text buffer is printed, all the pages will have a header and a footer. Contents (data and its co-ordinates) of both the header and footer should be given as inputs to the api. The api should automatically know whether to add the data to the next page.

I don't need an api that does all of the above, although that would be great . Just some would be good too, as I will be customizing them.

I am working for my college's office department. And they want a program from me which does batch printing. They want it to be done automatically. The data is stored in the database. My program needs to get the data from the database and create a text buffer and and print content. The print paper is actually a form and the data needs to be printed on this form at the correct positions. My prof. suggested me to use a third party api to speed up the development. The api/library can be commercial (I am not paying for it anyways ).

I have been on this for quite sometime. I have not yet found an api that fulfills my need.

I have attached an image which shows what I meant to say above.

Thanks,
harke
print_form.png
[Thumbnail for print_form.png]
sample print form
 
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I feel JasperReports frameworks will be a good fit for you. It allows:

1. Positioning of fields and layout (using JRXML report template)
2. Pulling data through a DB connection or other data source
3. Printing to a printer including on pre-printed paper (or to PDF, HTML, and other formats).

Check it out: JasperReports
 
harke baj
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the quick reply ,

I found another library called, PDFOne. Do you know how is this compared to JasperReports?

Thanks,
harke
 
Karthik Shiraly
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not familiar with PDFOne specifically, but it seems similar to iText which I'm familiar with.
The difference between these pure PDF libraries and JasperReports is in their scope :
PDFOne and iText are meant to only generate PDFs, which could be form PDFs or thesis PDFs or ebooks or really any kind of PDFs. Their domain is the PDF format.
JasperReports on the other hand focuses on reporting and its typical use cases - for example, most reporting requires data from a DB. So JR gives data query functionality to pull in data. Authoring something like an ebook with JR - while possible - will feel "unnatural" in code.

With pure PDF libraries, you have to write code to pull in data and then push it to the PDF lib. I expect using pure PDF libs will involve more coding, but it won't feel like more if you're already familiar with JDBC and producing PDFs.
On the other hand, JR involves a higher learning curve.
So choose based on your timeline and familiarity with technologies.

As for positioning and layout, iText too provides (x,y) positioning, adding headers/footers, and even form templates (where you create a template PDF once in memory and then keep filling it with data fields and printing out). Very likely, PDFOne also provides all this.
 
harke baj
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok,got it.

But could you point me to an example for using JasperReports in Eclipse IDE?

Most of the examples that I found used the manual process. Except one which showed how to use with JDeveloper.
I have never used Ant by itself, till now. The IDE took care of that. I will learn that soon, but right now because of time crunch, I need an example using Eclipse.

Thanks for all the help you have given.


Harke
 
Karthik Shiraly
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome!
I've always created JRXML manually - I'm not aware whether any Eclipse plugin exists to visually design a report.
They have a free product called iReport, but I've not used that either - you may want to try it if typing XML is not to your taste.

As for executing a JR app from eclipse, you don't really need ant or ant tasks.
The report can be compiled after app starts using JasperCompileManager.
This is not ideal and you should eventually move to precompiling report with ant, but for now, ignore the ant related info in the tutorial site.
 
harke baj
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Karthik,

I got some examples working. I am able to get the output in pdf but not in txt format. I tried some examples but i am still not clear. Could you tell me some examples using the text exporter?

Like, what is the value of the attribute "width" is in? Is it in pixels, dots or characters ? Also, how do I calculate the number of characters that i can put in a row or column, in a document, say in A4 paper?

Thanks,
harke
 
Karthik Shiraly
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I got some examples working. I am able to get the output in pdf but not in txt format. I tried some examples but i am still not clear. Could you tell me some examples using the text exporter?


You mentioned you needed the output on pre-printed paper. If so, there's no need to output to PDF or txt. Use JasperPrintManager instead.
However, text exporting examples (and many other examples) are available in the japerreports project download's demo folder. Use JRTextExporter.


Like, what is the value of the attribute "width" is in? Is it in pixels, dots or characters ? Also, how do I calculate the number of characters that i can put in a row or column, in a document, say in A4 paper?


All units are pixels. At 96dpi, 1 inch=96 pixels. So that's how you can convert coordinates and widths.
As for calculating number of characters, etc, this goes into the creative world of font metrics and really I've never needed to do this.
Use a textField with appropriate properties and let JR handle word wrapping, breaking, etc. The simpler the report is kept, the better. Stuff like calculating widths will break if you change to a different width paper later or a bigger margin or a different font, and so on. Best avoided.

Out of curiosity, I tried out iReport and actually liked it. You should try it out - makes report designs easier and faster.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Karthik,

The information in this thread was really useful to me. I am working on a J2EE project that has around 40 letter formats with some common template and unique data elements that I have to pull from the database and some user entered values. Once the user has generated a pdf document with all the information, the supervisor has to approve it with an e-signature. I may have to generate the pdf atleast twice once for the user to preview and once for the supervisor to sign. Then the generated pdf needs to be printed and/or saved to the database. Please advise if it is worth looking into jasperReports or do you have any other suggestions. We are using Eclipse IDE and Apache Tomcat Server. It really helps to speed up my process if you could provide me a sample application/tutorial.

Advise is really appreciated.

Thanks.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have a look at http://code.google.com/p/xdocreport/ which gives you the capability to create your report with MS Word (docx) or OpenOffice (odt), use mergefield with Freemarker/Velocity syntax and genrate report.
 
You showed up just in time for the waffles! And this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic