Change annotations to locked

PDF-XChange Editor SDK for Developers

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

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: 417
Joined: Sat May 16, 2009 1:55 pm

Change annotations to locked

Post by lidds » Thu Jul 20, 2017 8:29 am

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

User avatar
Sasha - Tracker Dev Team
User
Posts: 4325
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Change annotations to locked

Post by Sasha - Tracker Dev Team » Thu Jul 20, 2017 8:36 am

Hello Simon,

Please specify a mask value of 0x00400000.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

lidds
User
Posts: 417
Joined: Sat May 16, 2009 1:55 pm

Re: Change annotations to locked

Post by lidds » Thu Jul 20, 2017 9:37 am

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

User avatar
Sasha - Tracker Dev Team
User
Posts: 4325
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Change annotations to locked

Post by Sasha - Tracker Dev Team » Thu Jul 20, 2017 9:48 am

Hello Simon,

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

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

lidds
User
Posts: 417
Joined: Sat May 16, 2009 1:55 pm

Re: Change annotations to locked

Post by lidds » Thu Jul 20, 2017 9:57 am

Alex,

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

User avatar
Sasha - Tracker Dev Team
User
Posts: 4325
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Change annotations to locked

Post by Sasha - Tracker Dev Team » Thu Jul 20, 2017 10:01 am

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

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

lidds
User
Posts: 417
Joined: Sat May 16, 2009 1:55 pm

Re: Change annotations to locked

Post by lidds » Thu Jul 20, 2017 10:05 am

Alex,

Sorry my mistake.

Thanks all working now

User avatar
Sasha - Tracker Dev Team
User
Posts: 4325
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Change annotations to locked

Post by Sasha - Tracker Dev Team » Thu Jul 20, 2017 10:32 am

:)
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

Audros
User
Posts: 63
Joined: Fri Jun 08, 2018 1:39 pm

Re: Change annotations to locked

Post by Audros » Wed Feb 06, 2019 1:26 pm

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

User avatar
Sasha - Tracker Dev Team
User
Posts: 4325
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Change annotations to locked

Post by Sasha - Tracker Dev Team » Wed Feb 06, 2019 1:30 pm

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
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

Audros
User
Posts: 63
Joined: Fri Jun 08, 2018 1:39 pm

Re: Change annotations to locked

Post by Audros » Wed Feb 06, 2019 1:38 pm

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

User avatar
Sasha - Tracker Dev Team
User
Posts: 4325
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Change annotations to locked

Post by Sasha - Tracker Dev Team » Wed Feb 06, 2019 3:05 pm

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
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

Audros
User
Posts: 63
Joined: Fri Jun 08, 2018 1:39 pm

Re: Change annotations to locked

Post by Audros » Wed Feb 06, 2019 3:28 pm

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

User avatar
Sasha - Tracker Dev Team
User
Posts: 4325
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Change annotations to locked

Post by Sasha - Tracker Dev Team » Wed Feb 06, 2019 3:34 pm

Hello Audros,

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

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

Audros
User
Posts: 63
Joined: Fri Jun 08, 2018 1:39 pm

Re: Change annotations to locked

Post by Audros » Wed Feb 06, 2019 3:54 pm

Hello,
this operation avoid to set properties of annotations.
but what we want its to let that but make text readonly.

User avatar
Sasha - Tracker Dev Team
User
Posts: 4325
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Change annotations to locked

Post by Sasha - Tracker Dev Team » Wed Feb 06, 2019 4:02 pm

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
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

Audros
User
Posts: 63
Joined: Fri Jun 08, 2018 1:39 pm

Re: Change annotations to locked

Post by Audros » Wed Feb 06, 2019 4:06 pm

thank you :)

User avatar
Sasha - Tracker Dev Team
User
Posts: 4325
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Change annotations to locked

Post by Sasha - Tracker Dev Team » Thu Feb 07, 2019 7:25 am

:)
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

Post Reply