Select Annot by name  SOLVED

PDF-XChange Editor SDK for Developers

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

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.
Artsiom
User
Posts: 14
Joined: Fri Aug 23, 2019 7:22 am

Select Annot by name

Post by Artsiom »

While switching from PDF Viewer to PDF Editor, I encountered the following problem:
I need to select annot by name.

My PDF Viewer method:

Code: Select all

        public object SelectAnnot(string name)
        {
            var activeDocID = GetActiveDocument();
            if (activeDocID < 0)
            {
                return null;
            }
            
            pdfViewerControl.DoVerb(activeDocID, null, "SelectAnnot", name, out var vDataOut);

            return vDataOut;
        }
How to do it in the Editor SDK?
Sorry for this simple question, but I could not find the necessary information on the forum

Regards,
Artsiom
Sasha - PDF-XChange
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: Select Annot by name

Post by Sasha - PDF-XChange »

Hello Artsiom,

Well I did find an answer on forums by first searching for Select word and then for Annot word - just like your topic name advises:
search.php?st=0&sk=t&sd=d&sr=posts&keyw ... d%5B%5D=66

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Artsiom
User
Posts: 14
Joined: Fri Aug 23, 2019 7:22 am

Re: Select Annot by name

Post by Artsiom »

I have a lot of annotations per one page, I need to choose by name. Can you share a link to solve the problem?

Regards,
Artsiom
Sasha - PDF-XChange
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: Select Annot by name

Post by Sasha - PDF-XChange »

Hello Artsiom,

IPXV_Inst -> Active IPXV_Document -> IPXC_Document -> Pages -> IPXC_Page -> IPXC_Annotation (by index) -> Name property:
https://sdkhelp.pdf-xchange.com/vi ... ation_Name
Then add them to the selection like advised here:
viewtopic.php?f=66&t=27684&p=107499&hil ... ot#p107499

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Artsiom
User
Posts: 14
Joined: Fri Aug 23, 2019 7:22 am

Re: Select Annot by name

Post by Artsiom »

Thank you so much, Alex!
I can find my annotations by name now, but selection still doesn't work :(

Example:

Code: Select all

        public void SelectAnnot(string name)
        {
            var annotList = new List<IPXC_Annotation>();
            for (uint i = 0; i < pdfViewerControl.PagesCount; i++)
            {
                var page = pdfViewerControl.Doc.CoreDoc.Pages[i];
                var annotCount = page.GetAnnotsCount();
            
                for (uint j = 0; j < annotCount; j++)
                {
                    var annot = page.GetAnnot(j);
                    annotList.Add(annot);
                }
            }
            
            var requiredAnnot = annotList.FirstOrDefault(x => x.Name.Equals(name));
            
            if (requiredAnnot == null)
            {
                return;
            }
            
            var nSelID = pdfViewerControl.Inst.Str2ID("selection.annots", false);
            PDFXEdit.IPXV_AnnotSelection itSel = (PDFXEdit.IPXV_AnnotSelection) pdfViewerControl.Doc.CreateStdSel((uint) nSelID);
            itSel.Items.Insert(requiredAnnot);
            pdfViewerControl.Doc.ActiveSel = itSel;
            itSel.Highlight();
        }
        
Regards,
Artsiom
Sasha - PDF-XChange
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: Select Annot by name  SOLVED

Post by Sasha - PDF-XChange »

Hello Artsiom,

This code works for me:

Code: Select all

int nSelID = pdfCtl.Inst.Str2ID("selection.annots", false);
PDFXEdit.IPXV_AnnotSelection itSel = (PDFXEdit.IPXV_AnnotSelection)pdfCtl.Doc.CreateStdSel((uint)nSelID);
IPXC_Annotation annot = pdfCtl.Doc.CoreDoc.Pages[0].GetAnnot(0);
itSel.Items.Insert(annot);
pdfCtl.Doc.ActiveSel = itSel;
itSel.Show(true);
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Artsiom
User
Posts: 14
Joined: Fri Aug 23, 2019 7:22 am

Re: Select Annot by name

Post by Artsiom »

Thanks Alex, it works! :D
But earlier annotation highlighting was animated.
Is it possible to animate annotation?
Sasha - PDF-XChange
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: Select Annot by name

Post by Sasha - PDF-XChange »

What do you mean by animation?
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Artsiom
User
Posts: 14
Joined: Fri Aug 23, 2019 7:22 am

Re: Select Annot by name

Post by Artsiom »

So, look this. It's Viewer SDK select annot
You do not have the required permissions to view the files attached to this post.
Sasha - PDF-XChange
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: Select Annot by name

Post by Sasha - PDF-XChange »

Hello Artsiom,

Can you do that in the End-User Editor?

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Artsiom
User
Posts: 14
Joined: Fri Aug 23, 2019 7:22 am

Re: Select Annot by name

Post by Artsiom »

Of course!

This is annot in PDF-XChange Editor (End-User):
2019-09-06_15-30-39.gif

And PDF-XChange Viewer (End-User):
2019-09-06_15-24-48.gif
You do not have the required permissions to view the files attached to this post.
Sasha - PDF-XChange
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: Select Annot by name

Post by Sasha - PDF-XChange »

Hello Artsiom,

I do not see any animation in the Editor.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Artsiom
User
Posts: 14
Joined: Fri Aug 23, 2019 7:22 am

Re: Select Annot by name

Post by Artsiom »

It's true, but the animation was in the ViewerSDK, is it possible to return it?
Sasha - PDF-XChange
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: Select Annot by name

Post by Sasha - PDF-XChange »

Hello Artsiom,

Sadly no - there is no animation in the Editor.

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