Loop through just imported annotations...

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

Loop through just imported annotations...

Post by lidds »

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

Re: Loop through just imported annotations...

Post by Sasha - Tracker Dev Team »

Hello Simon,

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

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

Re: Loop through just imported annotations...

Post by lidds »

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

Re: Loop through just imported annotations...

Post by Sasha - Tracker Dev Team »

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
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Re: Loop through just imported annotations...

Post by lidds »

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

Re: Loop through just imported annotations...

Post by Sasha - Tracker Dev Team »

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
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Re: Loop through just imported annotations...

Post by lidds »

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

Re: Loop through just imported annotations...

Post by Sasha - Tracker Dev Team »

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
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply