Access new added annotation source when pasted in a document

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
User avatar
MartinCS
User
Posts: 153
Joined: Thu Apr 07, 2011 10:01 am
Contact:

Access new added annotation source when pasted in a document

Post by MartinCS »

Hi Tracker-Team,

I came accross an issue I had with the PDF-XChange Viewer SDK once, see related post: https://www.pdf-xchange.com/forum3 ... 421#p77421

The solution was that you guys created a new PXCVA_EventType named "Notifications.NewAnnotAdded" which also made it possible to read the property "Notifications.NewAnnotAdded.Source":

Code: Select all

If (e.type = PDFXCviewAxLib.PXCVA_EventTypes.PXCVA_OnNamedNotify) And (e.name = "Notifications.NewAnnotAdded") Then
' get window id
AxCoPDFXCview1.GetActiveDocument(nDocID)

' get source of new annot
AxCoPDFXCview1.GetProperty("Notifications.NewAnnotAdded.Source", vDataOut)

' new annot created
If (vDataOut = 0) Then ...

' pasted annot by user
If (vDataOut = 1) Then ...
Is there already a similar property/way in the Editor SDK? If not, is there a chance that you create a source property for the IPXC_Annotation Interface (https://sdkhelp.pdf-xchange.com/vi ... Properties)?

Thank you!

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

Re: Access new added annotation source when pasted in a document

Post by Sasha - Tracker Dev Team »

Hello Martin,

You can catch the https://sdkhelp.pdf-xchange.com/vi ... s_inserted event and get the annotations list from there.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
User avatar
MartinCS
User
Posts: 153
Joined: Thu Apr 07, 2011 10:01 am
Contact:

Re: Access new added annotation source when pasted in a document

Post by MartinCS »

Hi Alex,

I registered my application to the "e.annots.inserted" event and I'm also able to iterate the annotation list. But I can't find a property of the annotation which tells me if it was pasted by the user or created as a new annotation.

For me it is essential to know if the user pasted a already existing annotation of if the user created a new one.

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

Re: Access new added annotation source when pasted in a document

Post by Sasha - Tracker Dev Team »

Hello Martin,

Please clarify what do you mean by pasting an existing one.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
User avatar
MartinCS
User
Posts: 153
Joined: Thu Apr 07, 2011 10:01 am
Contact:

Re: Access new added annotation source when pasted in a document

Post by MartinCS »

Alex,

in our application and implemantation of the PDF Editor I do load pdf documents with annotions which different users created at different/earlier times. The current user of the pdf document can see all these annotations on the pdf document and he has the possibility to copy and paste these annotations. This is where I need to know if the new annot was created from scratch or was an existing annot.

For the Viewer SDK you guys implemented the notify event and property which I mentioned and refered in my initial post. Now, that I'm working on the implementation of the Tracker Editor in our application I do need the same functionallity.

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

Re: Access new added annotation source when pasted in a document

Post by Sasha - Tracker Dev Team »

Hello Martin,

Well, you can always catch the https://sdkhelp.pdf-xchange.com/vi ... oreExecute event and see whether it's an insert annotation operation. If so, mark this with some class-level boolean value and look for it in the event I mentioned before. This should work.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
User avatar
MartinCS
User
Posts: 153
Joined: Thu Apr 07, 2011 10:01 am
Contact:

Re: Access new added annotation source when pasted in a document

Post by MartinCS »

Hi Alex,

as far as I understand the Editor SDK there are five events I can register for annot operations:
  • e.annots.changed
    e.annots.deleted
    e.annots.inserted
    e.annots.visibilityChanged
    e.annotStateModelsChanged
And the "e.annots.instered" event is the only one which makes sense (like you suggested earlier). But my problem is that I'm not able to differ from an annot which is a new one and an annot which has been pasted. On both options the e.annots.inserted event is triggered which does not give me any further information about the annot except of IPXC_Annotation properties.

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

Re: Access new added annotation source when pasted in a document

Post by Sasha - Tracker Dev Team »

Hello Martin,
Well, you can always catch the https://sdkhelp.pdf-xchange.com/vi ... oreExecute event and see whether it's an insert annotation operation. If so, mark this with some class-level boolean value and look for it in the event I mentioned before (e.annots.inserted). This should work.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
User avatar
MartinCS
User
Posts: 153
Joined: Thu Apr 07, 2011 10:01 am
Contact:

Re: Access new added annotation source when pasted in a document

Post by MartinCS »

Hi Alex,

I'm sorry, but I still don't see a chance to differ if an annot was created or inserted (using copy and paste). The registered event for "e.annots.inserted" is fired every time and the eventId is always the same (value: 2478). I don't have a source property inside of the IPXC_Annotation object or the event object. This makes it impossible to check if the annot was copied or created.
21-12-_2017_12-55-24.jpg
21-12-_2017_12-53-35.jpg
Is there another option to get the source of the inserted annot (like it was in the PDF-XChange Viewer)?

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

Re: Access new added annotation source when pasted in a document

Post by Sasha - Tracker Dev Team »

Hello Martin,

Hmm, how about distinguishing them by the Creation Date then? This should work for you.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
User avatar
MartinCS
User
Posts: 153
Joined: Thu Apr 07, 2011 10:01 am
Contact:

Re: Access new added annotation source when pasted in a document

Post by MartinCS »

Alex,

don't you see a chance to add a new property 'source' to the IPXC_Annotation object similar you guys did it for the Viewer SDK?

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

Re: Access new added annotation source when pasted in a document

Post by Sasha - Tracker Dev Team »

Hello Martin,

Well we will think whether we can add a property like this. For the meanwhile - try using the date method - should work smoothly for you.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
User avatar
MartinCS
User
Posts: 153
Joined: Thu Apr 07, 2011 10:01 am
Contact:

Re: Access new added annotation source when pasted in a document

Post by MartinCS »

Hello Alex,

that would be awesome of you guys! Thank you!

Meanwhile, I will try your suggestion and keep this post open and will check back on it the next period of time.

// Martin
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17889
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Access new added annotation source when pasted in a document

Post by Tracker Supp-Stefan »

Thanks Martin!

keep us posted on how it goes with the suggestion!

Cheers,
Stefan
User avatar
MartinCS
User
Posts: 153
Joined: Thu Apr 07, 2011 10:01 am
Contact:

Re: Access new added annotation source when pasted in a document

Post by MartinCS »

Hi Alex,

your suggestion doesn't work because I found another issue when copying an existing annotation. The creation date of the copy is not updated to the current date as you can see here:
29-01-_2018_08-52-27.jpg
// Martin
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Access new added annotation source when pasted in a document

Post by Sasha - Tracker Dev Team »

Hello Martin,

The date itself is being copied along with the annotation - that can give you a hint that it's a copied annotation, not a newly inserted one. The one thing that differs in the copied annotations is the Name of the annotation.

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