I don't think tried running the code I sent. The code with the reinitializing 
of the ByteArrayOutputStream and without the reinitializing of the 
ByteArrayOutputStream returns the same result i.e. the concatenated document 
with the updated  form field. This is what was confusing me. The problem with 
is with the dynamic content using the Document class. Which I take it from your 
example below is wrong anyway.

Also, in no way was I blaming your book for my error.




-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Paulo Soares
Sent: Friday, January 19, 2007 12:38 PM
To: Post all your questions about iText here
Subject: Re: [iText-questions] (no subject)

Copying the book code without understanding it won't get you anywhere.
It should be:

ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfCopyFields copy = new PdfCopyFields(baos);
copy.addDocument(new PdfReader("c:\\coverpage.pdf"));
copy.addDocument(new PdfReader("c:\\BO_INTRO.pdf"));
copy.close();
PdfReader reader = new PdfReader(baos.toByteArray());
baos = new ByteArrayOutputStream();
PdfStamper stamper = new PdfStamper(reader,baos);
AcroFields form = stamper.getAcroFields(); 
form.setField("groupName", "My Group"); 
stamper.setFormFlattening(true); 

// put here your dynamic content (HeaderFooter won't work!)
// see page 57 in the book

stamper.close();


Paulo

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Tandon, Amrish
> Sent: Friday, January 19, 2007 5:19 PM
> To: Post all your questions about iText here
> Subject: Re: [iText-questions] (no subject)
> 
> I have based this code from  sections 2.3.1 and 2.3.2 of your 
> book. Also it would make sense to me if you told me what part 
> did not make sense. Also please understand I am new to iText.
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Paulo Soares
> Sent: Friday, January 19, 2007 11:49 AM
> To: Post all your questions about iText here
> Subject: Re: [iText-questions] (no subject)
> 
> Read the tutorial and then tell me from where you got the 
> code. It doesn't make sense.
> 
> Paulo 
> 
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf Of 
> > Tandon, Amrish
> > Sent: Friday, January 19, 2007 4:24 PM
> > To: Post all your questions about iText here
> > Subject: Re: [iText-questions] (no subject)
> > 
> > Any updates?
> > 
> > -----Original Message-----
> > From: Tandon, Amrish
> > Sent: Thursday, January 18, 2007 12:03 PM
> > To: 'Post all your questions about iText here'
> > Subject: RE: [iText-questions] (no subject)
> > 
> > Let me clarify.
> > 
> > The PdfCopyFields and PdfStamper are working fine. It is everything 
> > after the PdfStamper that is using the document to add 
> pages and the 
> > header/footer that is not doing anything.
> > 
> > 
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf Of 
> > Paulo Soares
> > Sent: Thursday, January 18, 2007 11:52 AM
> > To: Post all your questions about iText here
> > Subject: Re: [iText-questions] (no subject)
> > 
> > You have to reinitialize baos before using it in PdfStamper, it was 
> > closed in PdfCopyFields.
> > 
> > Paulo
> > 
> > > -----Original Message-----
> > > From: [EMAIL PROTECTED]
> > > [mailto:[EMAIL PROTECTED] On 
> Behalf Of 
> > > Tandon, Amrish
> > > Sent: Thursday, January 18, 2007 4:15 PM
> > > To: itext-questions@lists.sourceforge.net
> > > Subject: [iText-questions] (no subject)
> > > 
> > > Hello all. 
> > > 
> > > I need help! I am trying to use iText to build a PDF composed of 
> > > several other PDFs.and then add some dynamic content.  The
> > code below
> > > is what I have so far. It does not seem to take the page
> > additions and
> > > the header and footers.
> > > 
> > > 
> > >                 protected void doPost(HttpServletRequest request, 
> > > HttpServletResponse response) throws ServletException, IOException
> > > 
> > >         {
> > >                 
> > >                 try {
> > >                         
> > >                         
> > >                         ByteArrayOutputStream baos = new 
> > > ByteArrayOutputStream();
> > >                         
> > >                         //concatinate documents
> > >                         
> > >                         PdfCopyFields copy = new
> > PdfCopyFields(baos);
> > >                         copy.addDocument(new 
> > > PdfReader("c:\\coverpage.pdf"));
> > >                         copy.addDocument(new 
> > > PdfReader("c:\\BO_INTRO.pdf"));
> > >                         copy.close();
> > >                         
> > >                         //Update form field(s)
> > >                         
> > >                         PdfReader reader = new 
> > > PdfReader(baos.toByteArray());
> > >                         PdfStamper stamper = new 
> > > PdfStamper(reader,baos);
> > >                         AcroFields form = 
> stamper.getAcroFields(); 
> > >                         form.setField("groupName", "My Group"); 
> > >                         stamper.setFormFlattening(true); 
> > >                         stamper.close();
> > >                         
> > >                         reader = new 
> > > PdfReader(baos.toByteArray());     
> > >                         
> > >                         //Add dynamic content. 
> > >                         
> > >                         Document document = new 
> > > Document(reader.getPageSizeWithRotation(1));
> > >                         document.open();
> > >                 
> > >                         document.newPage(); 
> > >                         document.add(new Paragraph("Hello 
> World")); 
> > >                         document.add(new Paragraph(new 
> > > Date().toString()));
> > >                         document.newPage(); 
> > >                         document.add(new Paragraph("Hello World 
> > > Again"));
> > >                         document.add(new Paragraph(new 
> > > Date().toString()));
> > >                         
> > >                         //Add header and footer 
> > >                         document.setHeader(new HeaderFooter(new 
> > > Phrase("This is a header"),false));
> > >                         document.setFooter(new HeaderFooter(new 
> > > Phrase("This is a footer"),true));
> > >                         document.close();
> > >                         
> > >                         response.setHeader("Expires", "0"); 
> > >                         response.setHeader("Cache-Control",
> > > "must-revalidate, post-check=0, pre-check=0"); 
> > >                         response.setHeader("Pragma", "public"); 
> > >                         
> response.setContentType("application/pdf"); 
> > >                         response.setContentLength(baos.size()); 
> > >                         ServletOutputStream out = 
> > > response.getOutputStream();
> > >                         baos.writeTo(out); 
> > >                         out.flush(); 
> > >                 } catch (DocumentException e) { 
> > >                         e.printStackTrace(); 
> > >                 }
> > >                 
> > >                 
> > >                 
> > >                 
> > >         }


Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter 
informação confidencial ou legalmente protegida. A incorrecta transmissão desta 
mensagem não significa a perca de confidencialidade. Se esta mensagem for 
recebida por engano, por favor envie-a de volta para o remetente e apague-a do 
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de 
usar, revelar ou distribuir qualquer parte desta mensagem. 

Disclaimer:
This message is destined exclusively to the intended receiver. It may contain 
confidential or legally protected information. The incorrect transmission of 
this message does not mean the loss of its confidentiality. If this message is 
received by mistake, please send it back to the sender and delete it from your 
system immediately. It is forbidden to any person who is not the intended 
receiver to use, distribute or copy any part of this message.





Blue Cross Blue Shield of Florida, Inc., and its subsidiary and affiliate 
companies are not responsible for errors or omissions in this e-mail message. 
Any personal comments made in this e-mail do not reflect the views of Blue 
Cross Blue Shield of Florida, Inc.  The information contained in this document 
may be confidential and intended solely for the use of the individual or entity 
to whom it is addressed.  This document may contain material that is privileged 
or protected from disclosure under applicable law.  If you are not the intended 
recipient or the individual responsible for delivering to the intended 
recipient, please (1) be advised that any use, dissemination, forwarding, or 
copying of this document IS STRICTLY PROHIBITED; and (2) notify sender 
immediately by telephone and destroy the document. THANK YOU.


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to