Page 1 of 1

Change annotations to locked

Posted: Thu Jul 20, 2017 8:29 am
by lidds
I want to change annotation on a document all to locked via code. I do know that there is already a post on the forum for this and I have looked at this as well as the Wiki, and have got the following code. However it does not seem to lock the annotations, so I guess I am doing something wrong?

Code: Select all

    Public Sub LockAnnotations()
        Dim pSInt As PDFXEdit.IPXS_Inst = DirectCast(Me.docPreview.Inst.GetExtension("PXS"), PDFXEdit.IPXS_Inst)
        Dim nID As Integer = Me.docPreview.Inst.Str2ID("op.annots.setProps", False)

        Dim Op As PDFXEdit.IOperation = Me.docPreview.Inst.CreateOp(nID)
        Dim input As PDFXEdit.ICabNode = Op.Params.Root("Input")

        Dim page As PDFXEdit.IPXC_Page = myDoc.CoreDoc.Pages(0)
        Dim nPageCount As UInteger = page.GetAnnotsCount()

        For i As UInteger = 0 To nPageCount - 1
            Dim annot As PDFXEdit.IPXC_Annotation = page.GetAnnot(i)
            input.Add().v = annot
        Next

        If input.Count = 0 Then
            Return
        End If

        Dim options As PDFXEdit.ICabNode = Op.Params.Root("Options")
        options("Flags").v = 128
        Op.Do()
    End Sub
Thanks for the help

Simon

Re: Change annotations to locked

Posted: Thu Jul 20, 2017 8:36 am
by Sasha - Tracker Dev Team
Hello Simon,

Please specify a mask value of 0x00400000.

Cheers,
Alex

Re: Change annotations to locked

Posted: Thu Jul 20, 2017 9:37 am
by lidds
Alex,

Please could you give me an example of how to specify a mask value. I know this is probably coding 101, but would really help.

Code: Select all

Dim options As PDFXEdit.ICabNode = Op.Params.Root("Options")
options("Flags").v = "0x00400000"
Op.Do()
Thanks

Simon

Re: Change annotations to locked

Posted: Thu Jul 20, 2017 9:48 am
by Sasha - Tracker Dev Team
Hello Simon,

The flags value was correct - though the options(""Mask") value needs to be 0x00400000

Cheers,
Alex

Re: Change annotations to locked

Posted: Thu Jul 20, 2017 9:57 am
by lidds
Alex,

I seem to get an error when setting the Mask value?
MaskError.png

Re: Change annotations to locked

Posted: Thu Jul 20, 2017 10:01 am
by Sasha - Tracker Dev Team
That's because it's not a string but a number value.

Cheers,
Alex

Re: Change annotations to locked

Posted: Thu Jul 20, 2017 10:05 am
by lidds
Alex,

Sorry my mistake.

Thanks all working now

Re: Change annotations to locked

Posted: Thu Jul 20, 2017 10:32 am
by Sasha - Tracker Dev Team
:)

Re: Change annotations to locked

Posted: Wed Feb 06, 2019 1:26 pm
by Audros
Hello,
can you help us about locking annotd, how we can lock a freetext without missing the possibility to change its properties (content properties i mean). see picture bellow.
Best regards

Re: Change annotations to locked

Posted: Wed Feb 06, 2019 1:30 pm
by Sasha - Tracker Dev Team
Hello Audros,

Do you want to achieve that in your SDK based product only? Or do you want to create such an annotation so that it would behave like that in all of the PDF readers/editors?

Cheers,
Alex

Re: Change annotations to locked

Posted: Wed Feb 06, 2019 1:38 pm
by Audros
Hello Sir,
no,of course I'm looking for a solution to integrate into my SDK based product only.
Is that possible in all of the PDF readers/editors?
Thank you

Re: Change annotations to locked

Posted: Wed Feb 06, 2019 3:05 pm
by Sasha - Tracker Dev Team
Hello Audros,

You will have to catch the beforeOperationExecute event like described in this post:
viewtopic.php?f=66&t=31487&p=127569&hil ... ot#p127544
Then you will have to check whether it's a ModifyAnnots operation. If so, get the Mask from it and see what is currently being modified. If there is some flags that you do not need, then break the event and the operation execution.

Cheers,
Alex

Re: Change annotations to locked

Posted: Wed Feb 06, 2019 3:28 pm
by Audros
Hello,
thanks, but i can't find an operation that can avoid changz text and allow modify properties(color style of text ....)
in addition to that, is there any way to do this for just our tool(bubble wih arrow that we create) and not for all freetext annotations
Thank you

Re: Change annotations to locked

Posted: Wed Feb 06, 2019 3:34 pm
by Sasha - Tracker Dev Team
Hello Audros,

This is the operation that you will have to monitor:
https://sdkhelp.pdf-xchange.com/vi ... s_setProps

Cheers,
Alex

Re: Change annotations to locked

Posted: Wed Feb 06, 2019 3:54 pm
by Audros
Hello,
this operation avoid to set properties of annotations.
but what we want its to let that but make text readonly.

Re: Change annotations to locked

Posted: Wed Feb 06, 2019 4:02 pm
by Sasha - Tracker Dev Team
Hello Audros,

As I said before, if the operation has the flag that the contents were modified then you will have to break the operation.

Cheers,
Alex

Re: Change annotations to locked

Posted: Wed Feb 06, 2019 4:06 pm
by Audros
thank you :)

Re: Change annotations to locked

Posted: Thu Feb 07, 2019 7:25 am
by Sasha - Tracker Dev Team
:)