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.
GdViewer and GdPicturePDF annotation
Re: GdViewer and GdPicturePDF annotation
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).
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.
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 ?
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);
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));
}
}
}
}
}
Is there a way to translate mouse coordinate from viewer to pdf document ?
- Attachments
-
- pdf_annot.png (1.84 KiB) Viewed 7190 times
Re: GdViewer and GdPicturePDF annotation
Hi,
You should use something like this:
https://www.gdpicture.com/guides/gdpicture/web ... ution.html
You should use something like this:
https://www.gdpicture.com/guides/gdpicture/web ... ution.html
Who is online
Users browsing this forum: No registered users and 1 guest