Is there a standard way of setting RECT position for form field widgets? The Rect property in Python/Java has a format Rect(x1, y1, x2, y2) where x1, y1 are lower left coordinates and x2,y2 are upper right coordinates. I was expecting it to be like Rect(x, y, width, height) where x,y are top left coordinates. Is it not possible this way?
Similarly, when I use Stamp annotation, the Stamper class has Position property with top left coordinates which does not seem to be in sync with Rect property arguments. If I have to place Stamp annotation over the Signature field via Python api, how to place it in the right position?
1 No, PDF format stores Rects as any two points x1,y1,x2,y2, and this is what our API follows.
2 The Stamper class does not provide 100% control over the size+position of the output. It is for different use case.
If I have to place Stamp annotation over the Signature field
You would just use the Signature fields Widget annotation Rect to know the exact position of the field on the page, and use that Rect with either Annotation subclass, or ElementWriter API.
Why is using Stamper over top of a Field important for you?
Why not edit the field appearance itself?
You mean RECT coordinates x1,y1 can be top-left or bottom left and x2,y2 can be top-right or bottom right? I can use it any which way?
My use case is I am placing a Signature widget on the document and want to add a signature (base64 or image) using backend apis over it. For that I tried using Stamper class and it works for me, just that the correct position has to be known. Can you suggest if Stamper is the right choice for this or I should use ElementWriter?
Why not edit the field appearance itself?
Can I edit the Signature widget to add its value? So I should use SetValue method to add ElementWriter object there?
When I use CreateSignatureAppearance() method to add an image and save it onto an output pdf doc, I dont see the signature image in the pdf under Acrobat reader. However, if I render the same doc in PDFTron Viewer, it shows up. Similarly when I flattened the doc, then also it shows up. Any idea why the image dont show up in the output doc in Acrobat?
Also, when I use SignatureAppearance to update the signature on the widget using backend apis, it creates appearances element under the Widget in XFDF. But if I add a signature from docviewer onto the same document, it creates a Stamp annotation for each Signature widget. Why both the flows are different?
I am not sure why WebViewer does that. Placing one annotation over top of another is not something I would recommend doing.
However, I believe you might run into some issues with some PDF viewers if a Digital Signature Field only has an appearance, and not an actual Cryptographic signature. I believe Adobe might not show the appearance at all. So you might want to flatten the fields/annotations so the appearance is baked into the PDF and will show everywhere.
Yes that is how WebViewer is behaving. Adding signature over the widget is actually creating Stamp annotation. I thought iofdoing the same from backend to keep the behavior consistent. Using Stamper I could achieve it. If I use widget appearance to add signature that has issues with Adobe might create problems as we want to store the PDF with signature (without flattening) for troubleshooting.