Change annotations to locked

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Change annotations to locked

Post 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
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Change annotations to locked

Post by Sasha - Tracker Dev Team »

Hello Simon,

Please specify a mask value of 0x00400000.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Re: Change annotations to locked

Post 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
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Change annotations to locked

Post by Sasha - Tracker Dev Team »

Hello Simon,

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

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Re: Change annotations to locked

Post by lidds »

Alex,

I seem to get an error when setting the Mask value?
MaskError.png
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Change annotations to locked

Post by Sasha - Tracker Dev Team »

That's because it's not a string but a number value.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Re: Change annotations to locked

Post by lidds »

Alex,

Sorry my mistake.

Thanks all working now
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Change annotations to locked

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Audros
User
Posts: 77
Joined: Fri Jun 08, 2018 1:39 pm

Re: Change annotations to locked

Post 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
Attachments
example.png
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Change annotations to locked

Post 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
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Audros
User
Posts: 77
Joined: Fri Jun 08, 2018 1:39 pm

Re: Change annotations to locked

Post 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
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Change annotations to locked

Post 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
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Audros
User
Posts: 77
Joined: Fri Jun 08, 2018 1:39 pm

Re: Change annotations to locked

Post 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
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Change annotations to locked

Post 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
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Audros
User
Posts: 77
Joined: Fri Jun 08, 2018 1:39 pm

Re: Change annotations to locked

Post by Audros »

Hello,
this operation avoid to set properties of annotations.
but what we want its to let that but make text readonly.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Change annotations to locked

Post 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
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Audros
User
Posts: 77
Joined: Fri Jun 08, 2018 1:39 pm

Re: Change annotations to locked

Post by Audros »

thank you :)
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Change annotations to locked

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply