There are two questions here. The text annotation doesn't print because you don't have the proper flags set. the general use is:
 
switch (visibility) {
    case HIDDEN:
        field.setFlags(PdfAnnotation.FLAGS_PRINT | PdfAnnotation.FLAGS_HIDDEN);
        break;
    case VISIBLE_BUT_DOES_NOT_PRINT:
        break;
    case HIDDEN_BUT_PRINTABLE:
        field.setFlags(PdfAnnotation.FLAGS_PRINT | PdfAnnotation.FLAGS_NOVIEW);
        break;
    default:
        field.setFlags(PdfAnnotation.FLAGS_PRINT);
        break;
}
About the stamp even without the appearances it works correctly for the standard ones in reader 4, 5 and 6. You are missing the popup associated with the stamp. What I always do is to create the object in Acrobat to see what it's done and mimic the structure in iText.
 
Best Regards,
Paulo Soares


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Enoch Chan
Sent: Friday, June 04, 2004 8:51 AM
To: [EMAIL PROTECTED]
Subject: [iText-questions] PDF Annotation and Stamping

 
Sorry about this rather long posting!  I was trying to do some kind of PDF annotation and stamping (e.g. the "Received" chop) to simulate the similar functions that can be performed through Adobe Acrobat.  I seem to be able to add some kind of annotation to the PDF file, but the result doesn't seem to be fully compatible with the different acrobat readers. 
 
For example the Text annotaiton that I've added cannot be printed to the printer, but can be viewed on screen; the stamp annotation that I've added would depends on the name of the stamp being used does not "stick" with the PDF file and behaves differently from Acrobat Reader 5.0 and 6.
 
I would like to look for some pointers on if I am doing the annotation the right way by using the PDFStamper, or that I need to use other iText classes to do the annotation?  The code segements are included below for your information:
 
For Text/Note Annotation:
 
    // we create a reader for a certain document and get page count              
    PdfReader reader = new PdfReader(inFile);                                    
    int n = reader.getNumberOfPages();                                           
                                                                             
    // step 2: open a PDFStamper                                                 
    PdfStamper stamp = new PdfStamper(reader, new FileOutputStream(outFile));    
                                                                             
    // step 3: we add the annotation                                             
    int i = 0;                                                                   
    while (i < n) {                                                              
     i++;                                                                     
        PdfImportedPage page = stamp.getImportedPage(reader, i);                 
     if (i == 1) {                                                            
          stamp.addAnnotation(PdfAnnotation.createText(                        
               stamp.getWriter(), new Rectangle(topX, topY, bottomX, bottomY),  
               author, text, false, "Note"), i);                                
    }                                                                        
    stamp.close();   
 
For Image Annotation:
                                                            
 The call to PdfAnnotation.createText() is replaced by PdfAnnotation.createStamp() and uses the StampName such as "Approved" or "As Is" in Adobe 5, and "#DApproved" in Acrobat Reader 6.
 
Thanks for your kind help!
 
Regards
 

Reply via email to