Stop other user modifying other users comments...

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

Stop other user modifying other users comments...

Post by lidds »

What is the best way to stop users modifying other users annotations?

Thanks in advance

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

Re: Stop other user modifying other users comments...

Post by Sasha - Tracker Dev Team »

Hello Simon,

You will have to catch a https://sdkhelp.pdf-xchange.com/vie ... oreExecute event and see whether it's a Modify Annotations operation. If so, you can get it's input and see what annotations are being modified (use the forum search to find how to do this). If there are some that are prohibited then mark the event as Handled and set the Result to 1 - this will break the operation execution.

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

Re: Stop other user modifying other users comments...

Post by lidds »

Alex,

I have tried to implement the following. The event is firing, however even if I move the annotation element it is not getting returned as an AnnotsEvent? Also when I drag / move an annotation element it shows me dragging it, but the e.operBeforeEvent is not fired until mouse up, surely this event should fire as soon as I try to move the annotation element?

Code: Select all

Private Sub docPreview_OnEvent(sender As Object, e As AxPDFXEdit._IPXV_ControlEvents_OnEventEvent) Handles docPreview.OnEvent
If e.nEventID = nIDS(CInt(IDS.e_operBeforeExecute)) Then
            Dim annotsEvent As PDFXEdit.IPXV_AnnotsEvent = TryCast(e.pEvent, PDFXEdit.IPXV_AnnotsEvent)
            If annotsEvent IsNot Nothing Then
                Console.WriteLine("BeforeEvent is annotation item")
            End If
End If       
End Sub     
Am I doing something wrong?

Thanks

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

Re: Stop other user modifying other users comments...

Post by Sasha - Tracker Dev Team »

Please read more carefully:
Sasha - Tracker Dev Team wrote: You will have to catch a https://sdkhelp.pdf-xchange.com/vie ... oreExecute event and see whether it's a Modify Annotations operation. If so, you can get it's input and see what annotations are being modified (use the forum search to find how to do this). If there are some that are prohibited then mark the event as Handled and set the Result to 1 - this will break the operation execution.
Here's what you needed to search for on forums:

Code: Select all

PDFXEdit.IOperation oper = (PDFXEdit.IOperation)e.pFrom;
Then take the ID of the operation and see whether it's a needed operation. After that check the input array:

Code: Select all

PDFXEdit.ICabNode input = oper.Params.Root["Input"];
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Re: Stop other user modifying other users comments...

Post by lidds »

Hi Alex,

Thanks for your help.

Almost getting there with it now, however struggling on getting the author value of the annotation, obviously doing something wrong. I guess I need to somehow get the annotation element from the event?

Code: Select all

            Dim oper As PDFXEdit.IOperation = DirectCast(e.pFrom, PDFXEdit.IOperation)
            Dim input As PDFXEdit.ICabNode = oper.Params.Root("Input")
            Dim commands As String = Me.docPreview.Inst.ID2Str(oper.ID)

            Console.WriteLine("e: " & commands)

            If oper.ID = Me.docPreview.Inst.Str2ID("op.annots.move", False) Then
                Dim options As PDFXEdit.ICabNode = oper.Params.Root("Options")
                Dim annoUser As String = options("Author").v.ToString
                If annoUser = MISData.Instance.ADUserName Then
                    Console.WriteLine("Annotation move user the same")
                Else
                    Console.WriteLine("Annotation move user NOT the same")
                End If

            End If
Thanks in advance

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

Re: Stop other user modifying other users comments...

Post by Sasha - Tracker Dev Team »

Hello Simon,

Well there is no Author in these options here:
https://sdkhelp.pdf-xchange.com/vie ... ve_Options
You don't need the operation's options at all - you just have to get the IPXC_Annotation objects from the Input cab node.

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

Re: Stop other user modifying other users comments...

Post by lidds »

OK Alex,

But how do you do that?

Thanks

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

Re: Stop other user modifying other users comments...

Post by Sasha - Tracker Dev Team »

Hello Simon,

Look at the Input description here and at a sample available:
https://sdkhelp.pdf-xchange.com/vie ... nnots_move
Just cast a cab node elements of the array from the IUnknown to the IPXC_Annotation interface - that's all.

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

Re: Stop other user modifying other users comments...

Post by lidds »

Alex,

Sorry I must be very tired as I cannot see how the example code would is the same situation as the IPXC_Annotation element is past as a parameter.

I have tried the following, but still not working, obviously doing a lot wrong!!

Code: Select all

            Dim oper As PDFXEdit.IOperation = DirectCast(e.pFrom, PDFXEdit.IOperation)
            Dim input As PDFXEdit.ICabNode = oper.Params.Root("Input")
            Dim commands As String = Me.docPreview.Inst.ID2Str(oper.ID)

            Console.WriteLine("e: " & commands)

            If oper.ID = Me.docPreview.Inst.Str2ID("op.annots.move", False) Then
                Dim annoItems() As Object = input.v

                For i As Integer = 0 To annoItems.Length - 1
                    Dim annot As PDFXEdit.IPXC_Annotation = annoItems(i)
                    Console.WriteLine("AnnoType: " & annot.Type)
                Next
           End If
Thanks

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

Re: Stop other user modifying other users comments...

Post by Sasha - Tracker Dev Team »

Hello Simon,

What I meant was this:

Code: Select all

PDFXEdit.ICabNode input = pOp.Params.Root["Input"];
for (uint i = 0; i < input.Count; i++)
{
	PDFXEdit.ICabNode ai = input[i];
	IPXC_Annotation annot = ai.v as IPXC_Annotation;
}
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Re: Stop other user modifying other users comments...

Post by lidds »

Thanks Alex,

So now I have got the annotation element. How would I go about getting the Author of the annotation element?

Thanks in advance

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

Re: Stop other user modifying other users comments...

Post by Sasha - Tracker Dev Team »

Hello Simon,

This should help:
https://sdkhelp.pdf-xchange.com/vie ... rkup_Title

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply