Page 1 of 1

GdViewer and GdPicturePDF annotation

Posted: Thu Jul 06, 2017 10:25 pm
by Chess
Hi,

It seem that GdPicture.net GdViewer display PDF annotation as a bitmap : when mouse is over an annotation, nothing happen.
But using GdPicturePDF and GetAnnotationRect method, we have annotation coordinate.

So, how can we translate mouse coordinate in GdViewer to check if mouse position is on the annotation rectangle (GdPicturePDF.GetAnnotationRect) ?

Thanks.

Re: GdViewer and GdPicturePDF annotation

Posted: Fri Jul 07, 2017 7:29 am
by Chess
I try something like that :

The user click on PDF note (see attachement bellow). X and Y is current mouse coordinate (catch with mouseup event on GdViewer (GdViewer1)).
With the bellow code, I try to translate mouse coordinate to PDF coordinate (a,b).

Code: Select all

double a = 0, b = 0;
GdViewer1.CoordViewerPixelToDocumentInch(X, Y, ref a, ref b);
Using a,b, I read all PDF annotation, and try to catch an annotation. I check only annotation with text content.
fic is the same file as the one loaded in GdVIewer1. I'am looking for annotations with text only.

Code: Select all

            using (GdPicturePDF oGdPicturePDF = new GdPicturePDF())
            {
                GdPictureStatus status = oGdPicturePDF.LoadFromFile(fic, false);
                if (status == GdPictureStatus.OK)
                {
                    oGdPicturePDF.SetMeasurementUnit (PdfMeasurementUnit.PdfMeasurementUnitInch);
                    oGdPicturePDF.SelectPage(GdViewer1.CurrentPage);
                    var cnt = oGdPicturePDF.GetAnnotationCount();

                    for (int i = 0; i < cnt; i++)
                    {
                        if (oGdPicturePDF.GetAnnotationContents(i) != "")
                        {
                            float x = 0, y = 0, w = 0, h = 0;
                            oGdPicturePDF.GetAnnotationRect(i, ref x, ref y, ref w, ref h);

                            float lx = x + w;
                            float ly = y + h;

                            //if ( ((float)a >= x && (float) <= lx)  && ((float)a >= x && (float) <= lx) )
                            if (((float)a >= x && (float)a <= lx) && ((float)b >= y && (float)b <= ly))
                            {
                                MessageBox.Show("Texte = " + oGdPicturePDF.GetAnnotationContents(i));
                            }
                        }
                    }
                }
            }
This code don't work : I can't retrieve GdViewer1 mouse position in oGdPicturePDF annotation rectangle.
Is there a way to translate mouse coordinate from viewer to pdf document ?

Re: GdViewer and GdPicturePDF annotation

Posted: Thu Jan 31, 2019 5:28 pm
by Gabriela