Thank you. I do have the book, and I did try this, and it didn't work
(the annotation still shows up on AR 8), just like the code I supplied
in my first mail didn't (see below).

That was the whole reason I posted a question on this forum.

======================================================
PdfAnnotation pdfAnnotation = PdfAnnotation.createText(
stamper.getWriter(), new Rectangle(1, 1, 1, 1),
"Comment", false, null);
                                                           
PdfAnnotation.FLAGS_HIDDEN);
pdfAnnotation.put(PdfName.F, new PdfNumber(PdfAnnotation.FLAGS_READONLY
| PdfAnnotation.FLAGS_NOVIEW | PdfAnnotation.FLAGS_INVISIBLE |
PdfAnnotation.FLAGS_HIDDEN));

stamper.addAnnotation(pdfAnnotation, 1);

======================================================

P.S. There's a problem with my mail client. Apologies if you guys get a
double post.




On Sun, 2008-12-07 at 16:07 +0100, 1T3XT info wrote: 
> Sankha Subhra Dey wrote:
> > I was looking for a way to add
> > an invisible annotation. The code I wrote isn't working, which I had
> > posted in my original mail. And I was looking for a way to add the
> > information to the Private section in a PDF file.
> 
> Every mail sent to the mailing list contains this line:
> > Buy the iText book: http://www.1t3xt.com/docs/book.php
> 
> If you had read chapter 15, you'd have found out there's
> a method setFlags() that helps you. See attachment.
> plain text document attachment (InvisibleAnnotation.java)
> 
> import java.io.FileOutputStream;
> 
> import com.lowagie.text.Document;
> import com.lowagie.text.Phrase;
> import com.lowagie.text.Rectangle;
> import com.lowagie.text.pdf.PdfAnnotation;
> import com.lowagie.text.pdf.PdfBoolean;
> import com.lowagie.text.pdf.PdfName;
> import com.lowagie.text.pdf.PdfReader;
> import com.lowagie.text.pdf.PdfStamper;
> import com.lowagie.text.pdf.PdfString;
> import com.lowagie.text.pdf.PdfWriter;
> 
> /**
>  * This example was written by Bruno Lowagie. It is part of the book 'iText in
>  * Action' by Manning Publications. 
>  * ISBN: 1932394796
>  * http://www.1t3xt.com/docs/book.php 
>  * http://www.manning.com/lowagie/
>  */
> 
> public class InvisibleAnnotation {
> 
>       /**
>        * Creates a PDF file with annotations.
>        * 
>        * @param args
>        *            no arguments needed here
>        */
>       public static void main(String[] args) {
>               // step 1: creation of a document-object
>               Document document = new Document();
>               try {
>                       // step 2:
>                       PdfWriter writer = PdfWriter.getInstance(document,
>                                       new 
> FileOutputStream("without_annotation.pdf"));
>                       // step 3:
>                       document.open();
>                       // step 4:
>                       document.add(new Phrase("TEST"));
>               } catch (Exception e) {
>                       e.printStackTrace();
>               }
>               // step 5: we close the document
>               document.close();
>               
>               try {
>                       PdfReader reader = new 
> PdfReader("without_annotation.pdf");
>                       PdfStamper stamper = new PdfStamper(reader, new 
> FileOutputStream("with_annotation.pdf"));
>                       PdfAnnotation annotation = 
> PdfAnnotation.createText(stamper.getWriter(),
>                                       new Rectangle(200f, 400f, 300f, 500f), 
> "Help",
>                                       "This Help annotation was made with 
> 'createText'", false,
>                                       "Help");
>                       annotation.setFlags(PdfAnnotation.FLAGS_NOVIEW |
>                                       PdfAnnotation.FLAGS_INVISIBLE | 
> PdfAnnotation.FLAGS_HIDDEN);
>                       stamper.addAnnotation(annotation, 1);
>                       stamper.close();
> 
>               } catch (Exception e) {
>                       e.printStackTrace();
>               }
> 
>       }
> }
> ------------------------------------------------------------------------------
>  SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada. 
> The future of the web can't happen without you. Join us at MIX09 to help pave 
> the way to the Next Web now. Learn more and register at 
> http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.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


------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.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

Reply via email to