GdViewer and GdPicturePDF annotation

Discussions about PDF management.
Post Reply
Chess
Posts: 22
Joined: Mon Apr 23, 2012 6:02 pm

GdViewer and GdPicturePDF annotation

Post by Chess » Thu Jul 06, 2017 10:25 pm

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.

Chess
Posts: 22
Joined: Mon Apr 23, 2012 6:02 pm

Re: GdViewer and GdPicturePDF annotation

Post by Chess » Fri Jul 07, 2017 7:29 am

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 ?
Attachments
pdf_annot.png
pdf_annot.png (1.84 KiB) Viewed 6939 times

Gabriela
Posts: 436
Joined: Wed Nov 22, 2017 9:52 am

Re: GdViewer and GdPicturePDF annotation

Post by Gabriela » Thu Jan 31, 2019 5:28 pm


Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest