Recently we found Paul Madary's blog post about digital signatures in a Univeral Application (UWP) with iText 7, and we wanted to share it. Paul gracefully agreed to let us do that, and as a bonus we upgraded the code to be usable out-of-the-box with iText 7.1.3. The only change needed is the method SignDocumentSignature.

A big thank you to our Q3 top contributors!

There are so many people that contribute information to us in order to help improve our code, products and projects. We want to make sure that our top contributors are being recognized for the help they give and that they know how much we appreciate them.

Top menu

Breadcrumb

Why is my cell event not triggered?

I am expecting the cell event to be triggered for two cells, but it only triggers on the first cell. The difference appears to be that the cell event of the first cell is added to the cell before adding the cell to the table.

The reason why this matters is that I need to do some measurements of the table (and other things) and pass values into the constructor of the cell renderer. I can't take the table measurements until after I've added the cell to the table; which is why I need to set the cell renderer after the cell has been added to the table.

The cell parameter of the addCell() method is final and changing cell after it has been added to the PdfPTable has no effect, because the object is being copied using the PdfPCell copy constructor of either the PdfPHeaderCell class or the PdfPCell class. We work on a copy because as soon as a cell is added to a table, we perform different operations on that cell. Should we do these operations on the original cell, then that cell can't be reused (and that is what some people do: they create a cell once and then reuse it).

There may be a workaround for your problem though. You could retrieve the copied cell from the row:

PdfPRow row = table.getRow(0);
PdfPCell cell = row.getCells()[1];

And then add the cell event to that cell instance. It's not elegant, but it might work.

Thanks Bruno, good explanation. And the work-around does work. cheers for that.

How to distribute the radio buttons of a radio field across multiple PdfPCells?

Ready to use iText?

As always, if you have any technical questions, you can contact support with your valid support subscription or head over to one of our community support pages on Stack Overflow to see if your question has already been answered for our AGPL users.