One of either Get/SetRectCoordinatesOnDocumentInch has a bug

General discussions about GdPicture.NET.
Post Reply
accudave
Posts: 21
Joined: Tue May 12, 2015 6:07 pm

One of either Get/SetRectCoordinatesOnDocumentInch has a bug

Post by accudave » Fri Jul 17, 2015 4:19 am

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.

accudave
Posts: 21
Joined: Tue May 12, 2015 6:07 pm

Re: One of either Get/SetRectCoordinatesOnDocumentInch has a

Post by accudave » Fri Jul 17, 2015 7:41 am

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.

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: One of either Get/SetRectCoordinatesOnDocumentInch has a

Post by Loïc » Fri Jul 17, 2015 11:47 am

Hello,

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

Cheers,

Loïc

accudave
Posts: 21
Joined: Tue May 12, 2015 6:07 pm

Re: One of either Get/SetRectCoordinatesOnDocumentInch has a

Post by accudave » Tue Jul 21, 2015 7:11 pm

I am. I updated to be sure. I also found that this is only occurring with PDF files.

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: One of either Get/SetRectCoordinatesOnDocumentInch has a

Post by Loïc » Tue Jul 21, 2015 8:59 pm

Are you able to reproduce the problem is a standalone app?
Definitively, I can't reproduce it.

accudave
Posts: 21
Joined: Tue May 12, 2015 6:07 pm

Re: One of either Get/SetRectCoordinatesOnDocumentInch has a

Post by accudave » Tue Jul 21, 2015 9:21 pm

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.

benkayle9
Posts: 1
Joined: Wed Apr 13, 2022 7:04 am

Re: One of either Get/SetRectCoordinatesOnDocumentInch has a bug

Post by benkayle9 » Wed Apr 13, 2022 7:10 am

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.

Hope this helps. GdPicture is a pretty cool SDK.

Edit: the same problem exists for SetRectCoordinatesOnDocumentInch. You must multiply by GdViewer.Zoom.
___________________________
Valley All Star Moving Service

User avatar
Fabio
Posts: 173
Joined: Thu Aug 27, 2020 9:57 am

Re: One of either Get/SetRectCoordinatesOnDocumentInch has a bug

Post by Fabio » Wed Apr 13, 2022 4:24 pm

Hello there,

I created a ticket on our end to let the developers know about this issue.
I will keep you posted about any updates!

Thank you for the feedback.

Best regards,
Fabio

lewis72
Posts: 1
Joined: Wed Aug 03, 2022 9:37 pm

Re: One of either Get/SetRectCoordinatesOnDocumentInch has a bug

Post by lewis72 » Wed Aug 03, 2022 9:39 pm

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.

abhishek
Posts: 1
Joined: Thu Mar 23, 2023 10:38 am

Re: One of either Get/SetRectCoordinatesOnDocumentInch has a bug

Post by abhishek » Thu Mar 23, 2023 10:39 am

I also found that this is only occurring with PDF files.

Post Reply

Who is online

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