PdfStamper.addAnnotation().

Paulo 

> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] 
> Sent: Tuesday, February 09, 2010 2:28 PM
> To: [email protected]
> Subject: [iText-questions] Help with Adding a Form Field to 
> Existing PDF File
> 
> 
> Here is my Servlet code which I cannot get to work as far as 
> adding a new form field: 
> 
> protected void doGet(HttpServletRequest arg0, 
> HttpServletResponse arg1) throws ServletException, IOException { 
>                 HttpSession session = arg0.getSession(true); 
>                 
>                 arg1.setContentType("application/pdf"); 
>                  System.out.println("Here"); 
>                 //URL url = new URL(arg0.getParameter("url")); 
>                 URL url = new URL(arg0.getParameter("p1")); 
>                 String url2 = arg0.getParameter("p2"); 
>                 String url3 = arg0.getParameter("p3"); 
>                 
>                 System.out.println(url); 
>                 PdfReader reader = new PdfReader(url); 
>                 //PdfReader reader = new 
> PdfReader(templatePath + "somePDF.pdf "); 
> 
>                 try { 
>                         //PdfStamper stamper = new 
> PdfStamper(reader,arg1.getOutputStream()); 
>                         PdfStamper stamp = new 
> PdfStamper(reader, new FileOutputStream("c:\\PDFTest.pdf")); 
>                         PdfWriter writer = stamp.getWriter(); 
>                         AcroFields form = stamp.getAcroFields(); 
> 
>                         form.setField("Status0","Steven Lynn Dyke1"); 
>                         form.removeField("Status1"); 
>                         
>                         TextField tf = new TextField(writer, 
> new Rectangle(67, 785, 340, 800), "Who"); 
>                         tf.setText("Vee Dyke"); 
>                         tf.setFontSize(24); 
>                         tf.setVisibility(BaseField.VISIBLE); 
>                         writer.addAnnotation(tf.getTextField()); 
>                         
>                         stamp.setFormFlattening(true); 
>                     stamp.close(); 
>                 
>                         //StringBuffer javascript = new 
> StringBuffer(); 
>                         //javascript.append("JSSilentPrint(this)"); 
>   
>                         //PdfAction pdfAction= 
> PdfAction.javaScript(javascript.toString(), writer); 
>                         //writer.addJavaScript(pdfAction); 
>                         //stamper.close(); 
>                         System.out.println("Finished"); 
>   
>                 } catch (DocumentException de) { 
>                         de.printStackTrace(); 
>                         System.err.println("document: " + 
> de.getMessage()); 
>                 } 
>         } 
> 

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.


------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to