• 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

opening PDF from JSP

 
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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);
}
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic