Can I lock or noMove signature annotation?

Product: iOS

Product Version: PDFNet (3.0.3-12)

Please give a brief summary of your issue:
I imported the signature field by Xfdf and from docs:

But when I sign the signature field, the signature annotation can move anywhere on the document. It is like that (Two signatures are showing). I try set flags for signature annotation like: locked, noMove, … But it is still moveable, It seems not to work on ios/android. Is there any way to locked the signature annotation in the signature field?

Thanks.

Hi @hatn

Can you check that you’ve enabled the annotationPermissionCheckedEnabled property on ToolManager?

Next, the e_ptlocked annotation flag would need to be set for the annotation you wish to disable dragging on like such:

[annot SetFlag:e_ptLocked value:YES];

Hi @dchan

Thanks for your response. It seems to work like a charm on ios. But I tried android and it didn’t work.

Also, I can’t use Delete (the Delete item menu does not display) to change the signature after signing.
image

Hi @hatn,

Unfortunately to use the Delete menu item will require a different approach.

Instead of locking the annotation we can prevent the drag interaction from moving the annotation. See iOS and Android instructions for this below.

iOS instructions:

You would need to subclass the PTAnnotEditTool which is the tool used to handle moving/editing annotations.

We have a guide on how to subclass built-in Apryse classes here:

Then in your subclass you would override the pdfViewCtrl:onTouchesMoved:withEvent: to prevent the user’s interaction from moving the annotation:

class MyAnnotEditTool : PTAnnotEditTool
{
// prevent the touches from being processwed by the tool
    override func pdfViewCtrl(_ pdfViewCtrl: PTPDFViewCtrl, onTouchesMoved touches: Set<UITouch>, with event: UIEvent?) -> Bool {
       // check annot properties to determine if it should be draggable
       if let annot = self.currentAnnotation
       {
           // return true to prevent dragging
           return true
       }
    return super.pdfViewCtrl(pdfViewCtrl, onTouchesMoved: touches, with: event)
    }

// Optional function override to hide the resize widgets when selecting the annotation
    override func selectAnnotation(_ annotation: PTAnnot, onPageNumber pageNumber: UInt32, showMenu: Bool) -> Bool {
        let selectAnnotation = super.selectAnnotation(annotation, onPageNumber: pageNumber, showMenu: showMenu)
        selectionRectContainerView.hideResizeWidgetViews()
        return selectAnnotation
    }
}

Android instructions:

You can disable certain annotations from dragging by first checking a condition on mAnnot before returning false in onMove . For example the current sample only prevents dragging for ink annotations. It checks whether the annotation type is Annot.e_ink and if so returns false:

You could modify this to check only for your signature stamp annotations.

This would prevent the annotation from being moved by the user.

1 Like

hi @jamie

Thank you very much, it works like a charm :tada:

Hi @hatn,

Great! We’re glad to hear it!
Please get in touch with any other questions and we’ll do our best to help.