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