0

I am using "Spring MVC" web application and I need to generate a small 'PDF' file and send it to the printer. Generated 'PDF' will contain user information that can get from accessing the database.

Are there any open source tools that I can use for this ? I looked at 'Java Print API' but still did not came across with a proper solution.

Can anyone please give some guidance?

actually from the web app (spring mvc) lets say i clicked "Do Print Job" button and without showing print dialog ( windows print dialog) can i do printing in the background? assuming using the default printer ?

Sam
  • 2,055
  • 6
  • 31
  • 48

5 Answers5

2

Look into Apache FOP, iText, and PDFBox... they should give you a good starting point.

cjstehno
  • 13,468
  • 4
  • 44
  • 56
1

BIRT (http://www.eclipse.org/birt/phoenix/) is a great solution for that kind of stuff. You can use it as separate servlet or use the engine as a library in Your code.

ITCuties
  • 219
  • 1
  • 4
1

Jasper Reports is an excellent tool for doing exactly what you want. Jasper Reports

ChadNC
  • 2,528
  • 4
  • 25
  • 39
0

Another option would be to generate a document in LaTeX and render it as PDF. A bit ugly because it requires running external apps instead of just calling library functions, but you can do almost anything with regard to formatting and the PDF has a distinct touch (TeX fonts and text layout engine - a look I personally like very much).

Michał Kosmulski
  • 9,855
  • 1
  • 32
  • 51
  • Kosmulski - Thanks a lot for your answer.can you please provide me any link that i can go through about this "La Tex" tool? – Sam Mar 01 '12 at 00:43
  • LaTeX is a typesetting system - something like a word processor but more powerful (and not as easy to learn for the balance). It's popular especially for typesetting complex equations. The homepage is [here](http://www.latex-project.org/) and [Wikipedia](http://en.wikipedia.org/wiki/LaTeX) gives some general information and a simple example. You should have packages easily available for any Linux distro out there. – Michał Kosmulski Mar 01 '12 at 08:16
0

I would suggest looking at iText, Docmosis and JODReports. If you say more about your specific requirements then it might be more obvious about what would be the best options.

Paul Jowett
  • 6,513
  • 2
  • 24
  • 19
  • Thanks a lot for answering my question. actually from the web app (spring mvc) lets say i clicked "Do Print Job" button and without showing print dialog ( windows print dialog) can i do printing in the background? assuming using the default printer ? – Sam Mar 01 '12 at 13:52
  • Hi Sam. I was only answering the "generate" part of the question - sorry about that. Is your "Do Print Job" button in a browser page? If so, this part of your question is about background printing from a web page. Is that correct? – Paul Jowett Mar 02 '12 at 04:05
  • no problem jo..anyway thanks for the help. yes, button is on the jsp page. so when user click it can i do a background processing and generate a .PDF file and send it to the printer? – Sam Mar 02 '12 at 08:03
  • Hi Sam. Looks like the way to go is to open a new window which generates the PDF (by calling a server/url), then call window.print(); in javascript. Check http://stackoverflow.com/questions/4789803/print-a-pdf-via-javascript – Paul Jowett Mar 07 '12 at 09:12
  • Thanks for your help jo...i found a good example [here](http://krams915.blogspot.com/2012/01/spring-mvc-31-and-jasperreports-using_5116.html) currently i am following that tutorial. its on spring 3 and my project was based on spring 2.5. so i am doing some changes to embed this without annotations. Thanks again.. – Sam Mar 07 '12 at 15:25