PDFAnnotation check if the signature is filled

Hi,


I try to check which signature fields annotations are filed in.


I tried to get some values from the annotation but I can't tell if the signature field is filled.

I only found one thing. If signature field was filled annot.widgetStringValue return empty string ("").

If the field wasn't filled, annot.widgetStringValue return nil.


Here is me code:

private func setupAnnotation(page: PDFPage) {
        for annot in page.annotations {
            
            if annot.widgetFieldType == .button {
                
            }
            else if annot.widgetFieldType == .choice {
                
            }
            else if annot.widgetFieldType == .signature {
                let value = annot.value(forAnnotationKey: .widgetValue)
                print(value)
                
                print(annot.widgetStringValue)
                
                print(annot.accessibilityValue)
                print(annot.annotationKeyValues)
            }
            else if annot.widgetFieldType == .text {
                
            }
           
        }
    }


There is no property such as "isFilled", or "isSigned", or "hasValue".

How can I check if signature field is filled?

Accepted Reply

Not working,


I have a pdf with 2 signature fields, the first is signed, the second is not signed.

The test for signing for both fields returns false, and annot.contents is for both nil


EDIT:

I think it's a bug in PDFAnnotation, when I tried other PDF SDK so the check on Content works.


EDIT2:

The property of annotation "widgetStringValue" represents the value of the given annotation. It works for text, checkbox, radio and just some signature fields. Some signature fields don't work and I don't know why.

Replies

If you test annot.contents, if not filled, you'll get nil


So, you could test:

let signed = annot.contents != nil && annot.contents! != ""

Not working,


I have a pdf with 2 signature fields, the first is signed, the second is not signed.

The test for signing for both fields returns false, and annot.contents is for both nil


EDIT:

I think it's a bug in PDFAnnotation, when I tried other PDF SDK so the check on Content works.


EDIT2:

The property of annotation "widgetStringValue" represents the value of the given annotation. It works for text, checkbox, radio and just some signature fields. Some signature fields don't work and I don't know why.