Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Generation of Dynamic PDF/Word doc from the template

Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All.

After a long time here in this forum  

I am looking for a kind of solution where we have to dynamically generate pdf or word document based on some parameters using some predefined template. Now I need some suggestion, how to go ahead and attack the problem.
What I understand is to convert the template into a XML and then parse the XML and generate the PDF with the dynamic values on the run time. Please help me here with your suggestion or approach.

Thanks in advance
Saloon Keeper
Posts: 5809
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are various ways to tackle this, and it's hard to recommend one over the other given the lack of detail. You could use FlyingSaucer library to render CSS-styled XHTML or XML as PDF. Or, if you have highly regular data in XML form, you could use Apache FOP to render it to PDF using an XSL-FO stylesheet. If the data is rather irregular, writing code using the iText or PDFBox APIs to create PDFs would be an option.

Alternatively, you can create RTF templates and search-and-replace placeholders in that. RTF can be opened by just about any wordprocessor, so is a good substitute for actual Word files (which are much harder to create).
Try 100 things. 2 will work out, but you will never know in advance which 2. This tiny ad might be one:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!