Page 1 of 1

One of either Get/SetRectCoordinatesOnDocumentInch has a bug

Posted: Fri Jul 17, 2015 4:19 am
by accudave
In our application, we allow the user to define a rectangle on a PDF document using the WPF GdViewer control. When we use SetRectCoordinatesOnDocumentInch, and immediately call GetRectCoordinatesOnDocumentInch, the coordinates returned to not match what was passed to set. Here is some sample data.

double left = 0, top = 0, width = 0, height = 0;
DocumentViewer.SetRectCoordinatesOnDocumentInch(0.217080444, 0.226247683, 3.48402667, 0.363420218);
DocumentViewer.GetRectCoordinatesOnDocumentInch(ref left, ref top, ref width, ref height);

The results we get are
left
0.11824942749237347

top
0.226247683

width
3.48402667

height
0.363420218

There is something either wrong with the set method where it sets the wrong coordinates, or there is something wrong with the get method returning incorrect coordinates. Either way, there is some incorrect behavior. I want to blame the set method more, because the rectangle does not appear in the correct location.

Or, is there something else about the GdViewer that might be impacting the behavior of these two methods, that we might need to correct in our code?

We are observing this behavior on our existing documents, and we want to note that everything works fine using the prior version of our application, which uses GdPicture9 and the WinForms viewer. The code is virtually identical between the two, other than the minor naming differences from the changes to the WPF stuff.

There is definitely a bug I think, or broken backwards compatibility in terms of how the WPF documentViewer handles this compared to the old WinForms viewer.

Re: One of either Get/SetRectCoordinatesOnDocumentInch has a

Posted: Fri Jul 17, 2015 7:41 am
by accudave
I figured out the problem with your code. The problem is GetRectCoordinatesOnDocumentInch does not mathematically consider the Zoom amount of the DocumentViewer. Basically if you take the values returned by GetRectCoordinatesOnDocumentInch and divide that by GdViewer.Zoom you will get the correct coordinates that match the values set with SetRectCoordinatesOnDocumentInch.

This is only my preliminary look at the problem, so I haven't tested this thoroughly with various zoom modes, but so far I think I am on the right track. I can't see the code for that API since it is obfuscated, but there is definitely a hotfix needed for this particular API to some degree.

This problem is only present in the new WPF viewer. The old WinForms component does not have this problem.
Edit: the same problem exists for SetRectCoordinatesOnDocumentInch. You must multiply by GdViewer.Zoom.

Hope this helps. GdPicture is a pretty cool SDK.

Re: One of either Get/SetRectCoordinatesOnDocumentInch has a

Posted: Fri Jul 17, 2015 11:47 am
by Loïc
Hello,

Everything is working as expected form me. Are you using the latest release?

Cheers,

Loïc

Re: One of either Get/SetRectCoordinatesOnDocumentInch has a

Posted: Tue Jul 21, 2015 7:11 pm
by accudave
I am. I updated to be sure. I also found that this is only occurring with PDF files.

Re: One of either Get/SetRectCoordinatesOnDocumentInch has a

Posted: Tue Jul 21, 2015 8:59 pm
by Loïc
Are you able to reproduce the problem is a standalone app?
Definitively, I can't reproduce it.

Re: One of either Get/SetRectCoordinatesOnDocumentInch has a

Posted: Tue Jul 21, 2015 9:21 pm
by accudave
I will try to put something together this evening for you to find out. I'll attach the project solution or you if I can reproduce it as a standalone application.