hihi all,

i searched the archives and found this thread which explains how to set
the document properties:
 
http://article.gmane.org/gmane.comp.java.lib.itext.general/13105/match=document+properties

i have tried to incorporate the code into mine (trial and error because
i still really don't understand the iText model/API), but it still does
not work.

everything else working.  i have a pdf template with form fields.  i
read in this template and set the values of these fields in my java
object.  then i use the stamper to flatten the page.  then i add each
page to the writer.  then at the end, i close the document and pass
this document in the form of a byte array to the ServletOutputStream. 
everything works beautifully and the user's browser is displays the pdf
file i created.

but after incorporating the code, when i save the pdf file locally and
then open it (or right-click to view the file properties), the document
properties tab information is still blank (author, title, subject,
etc..).

i must be missing something or not using the code properly.  can anyone
please advise?

this is the basic structure of my code with the new part added between
the comments:

  PdfReader reader = new PdfReader("my_template.pdf");
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  PdfStamper stamp = new PdfStamper(reader, baos);
  AcroFields form = stamp.getAcroFields();
  form.setField("myfield", "hello");

  // setting the document properties (begin):
  PdfStream xmp = new PdfStream("xmptext".getBytes("UTF-8"));
  xmp.put(PdfName.TYPE, PdfName.METADATA);
  xmp.put(PdfName.SUBTYPE, new PdfName("XML"));
  xmp.put(PdfName.AUTHOR, new PdfName("Me!"));
  PdfIndirectReference ref =
writer.addToBody(xmp).getIndirectReference();
  reader.getCatalog().put(PdfName.METADATA, ref);
  // setting the document properties (end):

  stamp.setFormFlattening(true);
  stamp.close();
  PdfReader tempRead = new PdfReader(baos.toByteArray());
  writer.addPage(writer.getImportedPage(tempRead, 1));
  doc.close();

in the end, i just want to be able to set the document property values
for things like title, author, subject, etc., so that they are seen
when right-clicking on the pdf file or viewing them from within Acrobat
reader (File/Document Properties).

any help is much appreciated!  please and thanks!

woodchuck


                
__________________________________ 
Do you Yahoo!? 
Take Yahoo! Mail with you! Get it on your mobile phone. 
http://mobile.yahoo.com/maildemo 


-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to