• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to generate PDF files in Java

 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was wondering if someone might be able to point me in the right direction. I need to generate PDF files from XML. These PDF files are format intensive. Does anyone know of what API I should use to achieve this. I was also wondering if anyone has used a program to take a PDF file and transform it to a Formated Object(FO) since this would save me a ton of time not writing my own style sheet myself. I'm guessing I'm going to want to use an XSL-FO style sheet to transform my xml to a PDF document.
Any help would be appreciated.
Cheers
Ryan
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm on a project and we're doing the exact same thing. We choose to go the XMS/XSLT -> XSL:FO route. It works and is very flexible. One of the main benefits of doing this is that we can specify several different output formats for the same data. We use the Apache FOP library for this.
Creating the XSLT's that do the transformation can be quite time consuming and very overwhelming. If you don't need to specify multiple formats, I'd look into something a little bit simpler. I know many people who have used the iText library and like it very much. With iText you can specify the output formatting in your java code instead of in an external XSLT.
I guess my recommendation would be to go with XSL:FO if you 1) need multiple output formats of the same data and/or 2) already have an XSLT guru available.
HTH!
Terry
 
Ryan Bailey
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Terry,
Thank you very much for your response. You are doing exactly what I'm trying to accomplsih at work. I only need one format and that is PDF. I wasn't sure how easy it was to do formating using XSL-FO versus iText. It does look like you can do quite a bit of formating using iText. The PDF files that I need to generate are very conditional and have a lot of formating to be done. Do you know how easy it is to do formating and applying logic using XSL-FO?
Thank you again!
Cheers
Ryan
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I worked on this problem earlier.
The solutions could be:-
1. Pdf templates. If we have pdf templates and wants to do just like mail merge use FDF toolkit from Adobe.
2. If we want to convert data to different file formats we can use XSL:FO
3. We can Programmatically build pdf files using iText.
4. We can design templates using designing tools like Actuate and convert to pdf after merging data.
5. We can design a template using FO compatible tools like XSLfast and then use XSL:FO to convert to different file formats.
I want to know if anybody tried converting HTML templates to pdf using XSL:FO. I found a stylesheet on IBM site but that is expexting HTML to be as per XML format. But I would like to create HTML in Word 2000 to convert to pdf. I tried WORDTOHTML (sourceforge project) but that is failing for complicated WORD files. Has anybody have solution. could you please let me know.
 
Ryan Bailey
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ashok,
Do you know of any other free XSL-FO generators like XSLfast. I was thinking about just using iText, but if I can find a tool to generate all the grunt work, like formating my pdf document, I'll use XSL-FO.
Thank you again,
Ryan
 
Ashok Talluri
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
XMLSpy has FO compatible Editor. It is not free but you organisation might be using somewhere. I am not aware of any free editors. but if the files are simple create html convert to fo using stylesheet available on ibm site and go from there.
 
Terry Durkin
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ryan,
Just to clarify... The only file type that we're outputting now is PDF. When I said that we have multiple formats, I meant that we provide several different views of the same data via several different XSLTs. This was one of the main advantages of XSLT/XSL:FO for us. Should have been more clear. Sorry.
We started our XML/XSLT/XSL:FO development about a year ago. At that time there were no visual XSL:FO editors available. Right now there are a couple that I'm aware of (XSLfast and Scriptura). Neither of them are free/open source but the both have a 30 day trial. Scriptura seems to me like it's more of a complete document engine rather than a simple editor. I spent very little time on both of these tools as we do not have any active XSLT development going on at the moment, so take my comments with a grain of salt I'd imagine that we'll start seeing some free/open source WYSIWYG editors in the next 6-12 months, but that's just another guess.
Terry
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is another 3rd party tool "HTMLDOC" that can convert html pages to PDF...I.E. Data to JSP to PDF...Easy to amend the report layout in the future...
Hope this helps.
 
Ryan Bailey
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

There is another 3rd party tool "HTMLDOC" that can convert html pages to PDF...I.E. Data to JSP to PDF...Easy to amend the report layout in the future...
Hope this helps.


That looks like a great tool, but do you know of any that are free?
Cheers
Ryan
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic