I am trying to create custom digital signatures using iText (sharp, version 5.5.13) where the user is able to set the image location from a set of four positions (top, bottom, left and right), as shown below:
Rigth:
Left:
Top:
Bottom:
So far I tried working on layer 0 of the signature but I think I doing it wrong because signature details are set in layer 2.
Nevertheless, this is just an initial sketch to set position of the images. In the following code I load the image and put it in a chunk (idea taken from this example)
PdfTemplate pdfTemplate = sap.GetLayer(0);
ColumnText c1 = new ColumnText(pdfTemplate);
Image img = Image.GetInstance(signatureImage);
Phrase elements = new Phrase();
elements.Add(new Chunk(img, 0, 0, true));
//c1.SetSimpleColumn(elements, 0, 0, rectangle.Width, rectangle.Height / 4, 0, Element.ALIGN_CENTER); // align bottom
//c1.SetSimpleColumn(elements, 0, rectangle.Height / 2, rectangle.Width, rectangle.Height, 0, Element.ALIGN_CENTER); // align top
c1.SetSimpleColumn(elements, rectangle.Width/2, 0, rectangle.Width, rectangle.Height, 0, Element.ALIGN_CENTER); // align right
//c1.SetSimpleColumn(elements, 0, 0, rectangle.Width/2, rectangle.Height, 0, Element.ALIGN_CENTER); // align left
c1.Go();
The result is more or less the expected, but there are two problems: the signature information takes over the whole rectangle (this is normal since I do not modify layer 2, and the image in layer 0 is not scaled as it should)
If I scale the image to fit the column, it goes to the top of rectangle:
Is there any way to do this "out of the box" or I need to overload the method that builds the signature appearance (like this) and how can I achieve this?