• 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 ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

opening PDF from JSP

 
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
I want to open a pdf file from a JSP. I have seen a lot of code which reads a file and output it as PDF.But my requirement is that, i have a object and i want to use that object to fill up data in pdf from a jsp. i.e opening a pdf file from JSP which will comtain data from my object(suppose customer object)
Is there any way to do that ??
Thanks
kundan
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you want to programmatically create the PDF? You'd need to look at something like The Big Faceless Java PDF library for that.
 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can use itext as well...its really flexible.......it makes things easier.

http://www.lowagie.com/iText/

What you have to do is: provide the pdf file.

What itext does for you is open the pdf file, collect the names of the fields for you and populate them for you and write it back to the pdfwriter. Once you have the pdf (as a byte array) you can output it using servletoutputstream.

getting the fields is as:
PdfReader pdfReader = new PdfReader(pdfInBytes);
PdfStamper stamp = new PdfStamper(pdfReader, out);
AcroFields form = stamp.getAcroFields();


for (Iterator i = pdfReader.getAcroForm().getFields().iterator(); i.hasNext() {
//get each field
PRAcroForm.FieldInformation field = (PRAcroForm.FieldInformation) i.next();
form.setField(field.getName(), your value you want to set);
}
 
And tomorrow is the circus! We can go to the circus! I love the circus! We can take this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!