himvj1 0 Newbie Poster

Hi

I am working on Pdf annotation using Itextsharp.
I am able to get hyperlink url from pdf using the below code.

How to get the annotation (Highlited) text from pdf.

string[] PdfFiles = Directory.GetFiles("C:\\ABK");
            foreach (string fi in PdfFiles)
            {
                try
                {
                    PdfReader reader = new PdfReader(fi);
                    // Pagination
                    for (int i = 1; i <= reader.NumberOfPages; i++)
                    {
                        PdfDictionary pageDict = reader.GetPageN(i);
                        PdfArray annotArray = (PdfArray)PdfReader.GetPdfObject(pageDict.Get(PdfName.ANNOTS));
                        if (annotArray == null) continue;
                        if (annotArray.Length <= 0) continue;
                        // check every annotation on the page
                        foreach (PdfObject annot in annotArray.ArrayList)
                        {
                            PdfDictionary annotDict = (PdfDictionary)PdfReader.GetPdfObject(annot);
                            if (annotDict == null) continue;
                            string subtype = annotDict.Get(PdfName.SUBTYPE).ToString();

                          if (subtype != "/Link") continue;
                     
                          dfDictionary linkDict = (PdfDictionary)annotDict.GetDirectObject(PdfName.A);
                            if (linkDict == null) continue;
                            // if it makes it this far, its an Anchor annotation
                            // so we can grab it's URI
                            string sUri = linkDict.Get(PdfName.URI).ToString();
                            if (String.IsNullOrEmpty(sUri)) continue;
                        }
                    }
                    reader.Close();
                }

Thanks in advance