Loop through just imported annotations...

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

Loop through just imported annotations...

Post by lidds » Thu Jan 04, 2018 9:04 am

What I want to do is just be able to loop through the annotation items that are imported. I am capturing the op.document.importCommentsAndFields, however I am not sure how to just loop through the annotation elements being imported?

Obviously the below code loops through all annotations on the document, NOT just the ones being imported.

Code: Select all

                ElseIf oper.ID = Me.docPreview.Inst.Str2ID("op.document.importCommentsAndFields", False) Then
                    Dim nID As Integer = Me.docPreview.Inst.Str2ID("op.annots.delete", False)
                    Dim Op As PDFXEdit.IOperation = Me.docPreview.Inst.CreateOp(nID)

                    Dim annotsList As PDFXEdit.IPXV_AnnotsList = pxvInst.CreateAnnotsList()
                    For i As UInteger = 0 To Me.docPreview.Doc.CoreDoc.Pages.Count - 1
                        Dim page As PDFXEdit.IPXC_Page = Me.docPreview.Doc.CoreDoc.Pages(i)
                        Dim nCnt As UInteger = page.GetAnnotsCount()
                        For j As UInteger = 0 To nCnt - 1
                            Dim annot As PDFXEdit.IPXC_Annotation = page.GetAnnot(j)

                            If annot.IsMarkup Then
                                Dim data As PDFXEdit.IPXC_AnnotData = annot.Data
                                Dim mData As PDFXEdit.IPXC_AnnotData_Markup = DirectCast(data, PDFXEdit.IPXC_AnnotData_Markup)

                                Console.WriteLine("username: " + mData.Title)
                                Console.WriteLine("department: " + mData.Subject)

                            End If
                        Next
                    Next
Thanks

Simon

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

Re: Loop through just imported annotations...

Post by Sasha - Tracker Dev Team » Thu Jan 04, 2018 10:03 am

Hello Simon,

You can get the information from the SrcFile in the Operation's options:
https://sdkhelp.tracker-software.com/vi ... ds_Options

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

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

Re: Loop through just imported annotations...

Post by lidds » Mon Jun 03, 2019 1:44 pm

Alex,

I have looked at the link provided and am unable to determine how I can get the annot element of just the imported file. Is it possible for you give me a code snippet, I have got pretty good with the SDK, but can't figure this one out.

Thanks for your help

Simon

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

Re: Loop through just imported annotations...

Post by Sasha - Tracker Dev Team » Mon Jun 03, 2019 2:39 pm

Hello Simon,

Sorry, I've misread your question. I think you have found a solution to this one earlier:
viewtopic.php?f=66&t=30017&p=118608&hil ... ds#p118622

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

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

Re: Loop through just imported annotations...

Post by lidds » Tue Aug 13, 2019 4:12 pm

Alex,

Sorry this was my mistake, the annots.changed event was firing because I was performing some other changes further down in my code.

Therefore I still require some help on this that I only wish to process the annotations that are being imported, NOT all annotations on a document. As you could imagine I could have 100 annotations on the document, I then import in an annotation .fdf file that only has 10 new annotations, I only want to process those 10 annotations, not all 110 annotations on the document.

Thanks

Simon

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

Re: Loop through just imported annotations...

Post by Sasha - Tracker Dev Team » Wed Aug 14, 2019 6:45 am

Hello Simon,

Well, you can mark that you are doing the import in the beforeOperationExecute event, then listen to the needed event and if that marker is valid - process those annotations.

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

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

Re: Loop through just imported annotations...

Post by lidds » Wed Aug 14, 2019 3:27 pm

Alex,

The problem is that I cannot find any event that is fired when importing annotations that would allow me to get just the annotations being imported. When the op.document.importCommentsAndFields operation is called I would have expected the e.annots.inserted to be fired, or the op.annots.addNew to be used, but this does not seem the case. I am therefore a little stuck as to how I can get this?

Thanks

Simon

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

Re: Loop through just imported annotations...

Post by Sasha - Tracker Dev Team » Thu Aug 15, 2019 7:23 am

Hello Simon,

Then you will have to use the other way. Before the operation is executed you will have to run through all of the pages and store the annotations that are already in the document (in C++ this would be done via pointers). Then, after the operation had been executed, run through all of the annotations again and see what annotations are not in your stored list. This way, you will have all of the annotations that were imported.

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

Post Reply