Esempio n. 1
0
        // ********************************************************************
        // Fct:     GetNextPdfComment
        //
        // Descr:   -
        //
        // Owner:   erst
        // ********************************************************************
        private static bool GetNextPdfComment(PdfPage page, ref float x, ref float y, ref string content, ref int annotNo)
        {
            // Collects all comment annotations in the document
            Collection <PdfAnnotation> annotations = new Collection <PdfAnnotation>(page.GetAnnotations());

            while (annotNo <= annotations.Count)
            {
                PdfAnnotation annot = annotations[annotNo - 1];   // Array starts with index 0, annotNo starts with 1
                if (annot.GetType().Equals((typeof(iText.Kernel.Pdf.Annot.PdfTextAnnotation))))
                {
                    PdfDictionary annotDictionary = annot.GetPdfObject();

                    //Rect is the annotation rectangle defining the location of the annotation on the page
                    PdfArray Arr = annotDictionary.GetAsArray(PdfName.Rect);

                    //int x = Arr.GetAsNumber(0).IntValue();
                    //int y = Arr.GetAsNumber(1).IntValue();

                    Rectangle rect = annotDictionary.GetAsRectangle(PdfName.Rect);
                    x = rect.GetX();
                    y = rect.GetY();

                    //Read the content
                    content = annotDictionary.Get(PdfName.Contents).ToString();

                    annotNo++;
                    return(true);
                }
                else
                {
                    annotNo++;
                }
            }

            return(false);
        }