Product: PDFNet SDK for C#
Product Version: 9.3.0
Please give a brief summary of your issue:
Inserting an image on a PDF at the mouse position
Please describe your issue and provide steps to reproduce it:
I want to insert an image on a PDF document by choosing the position with the mouse. I have tried a lot to find the right coordinates but unfortunately no success. Please find below my current code which still inserts the image at a wrong position. What am I doing wrong? Thanks for help! N
/* position of top-left corner of Form1 (screen coords) */
_currentFormPosition = this.Location;
/* offset from viewer to Form1 (screen coords) */
_currentViewerOffset = _pdfView.Location;
/* position of the viewer (screen coords) */
_currentViewerPosition = new System.Drawing.Point(
_currentFormPosition.X + _currentViewerOffset.X,
_currentFormPosition.Y + _currentViewerOffset.Y
);
/* mouse position on the screen (screen coords) */
_currentMousePosition = new System.Drawing.Point(
MousePosition.X,
MousePosition.Y);
/* position of the mouse on the viewers canvas */
_currentScreenPosition = new System.Drawing.Point(
_currentMousePosition.X - _currentViewerPosition.X,
_currentMousePosition.Y - _currentViewerPosition.Y
);
/* image insertion point */
int index = _pdfView.GetCurrentPage();
double x = (double)_currentScreenPosition.X;
double y = (double)_currentScreenPosition.Y;
_pdfView.ConvScreenPtToPagePt(ref x, ref y, index);
_currentInsertionPosition = new PointD(x, y); // still wrong