On 4/08/2011 21:08, Sanjeev Sharma wrote:
> 1. I have purchased the book
>   - caption for the 2nd bullet in the list of page 127 is rect.
>
> I have read chapter 5

OK, the rect parameter is very important.

Create an implementation of the cell event interface.

For instance:

public class MyAnnotationCell implements PdfPCellEvent {
     protected PdfWriter writer;

     public MyAnnotationCell(PdfWriter writer) {
         this.writer = writer;
     }

     public void cellLayout(PdfPCell cell, Rectangle rect, 
PdfContentByte[] canvas) {
         // to know what to put here, scroll down
     }
}

Now when you have a PdfPTable, you can add PdfPCell objects.
One of those cells, annotationCell, needs to contain an annotation.

annotationCell.setCellEvent(new MyAnnotationCell(writer));

Because of the above line, iText will invoke the cellLayout() method,
as soon as the cell is drawn. This is why you need to put the code
to draw the annotation in the cellLayout method (where it says
"// to know what to put here, scroll down").

> I am not able to make connection between the following:
> Rectangle - annotation and RichMediaAnnotation since this does not extend
> of PdfAnnotation (for embedding the swf).

Skip to page 553.
In the cellLayout() method, you can put all the code from the line
"RichMediaAnnotation richMedia" until 
"writer.addAnnotation(richMediaAnnotation);",
but don't forget to replace the hard-coded "new Rectangle(36, 400, 559, 
806)" with
the rect parameter that is passed to the cellLayout() method.
Note that you have an instance of the writer, because you passed this object
when creating the cell event.

These are the simple principles.
It goes without saying that there's plenty of room for improvement.
For instance: you could replace the hard-coded RESOURCE and swf names
by membervariables of your cell event implementation. You can set these
variables in the constructor, or use setters.

I hope this helps.

------------------------------------------------------------------------------
BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to