If you added the signature using WebViewer, then the signature is actually added over top of the Digital Signature field with a Freehand/Ink annotation.
You can track the bounding boxes of the signature field, and look for an Ink annotation that has the same bounding box.
I tried the approach but it’s working for text or image upload, not for drawing.
Here is the code which I’m trying.
itr = doc.GetFieldIterator()
while itr.HasNext():
if itr.Current().GetType() == Field.e_signature and itr.Current().IsAnnot():
signature_found = False
print("Signature field name: " + itr.Current().GetName())
print("Traversing all annotations in the document...")
page_num = 1
page_itr = doc.GetPageIterator()
sig_widget = Annot(itr.Current().GetSDFObj())
sig_widget_rect = sig_widget.GetRect()
while page_itr.HasNext():
page_num = page_num + 1
page = page_itr.Current()
num_annots = page.GetNumAnnots()
i = 0
while i < num_annots:
annot = page.GetAnnot(i)
if not annot.IsValid():
continue
if annot.GetType() == Annot.e_Ink or annot.GetType() == Annot.e_Stamp:
ink_rect = annot.GetRect()
if (sig_widget_rect.Contains(ink_rect.x1, ink_rect.y1) or
sig_widget_rect.Contains(ink_rect.x1, ink_rect.y2) or
sig_widget_rect.Contains(ink_rect.x2, ink_rect.y1) or
sig_widget_rect.Contains(ink_rect.x2, ink_rect.y2)):
signature_found = True
i = i + 1
page_itr.Next()
print()
if signature_found:
print("Signature found")
else:
print("No signature found")
print("------------------------------")
itr.Next()
Could you please elaborate on exactly what you get, and what you expected to get instead, with regards to the code you provided and the corresponding PDF.