Different coordinates on PDF and TIF files

Discussions about document viewing.
Post Reply
DBr
Posts: 21
Joined: Thu Dec 09, 2010 8:21 pm

Different coordinates on PDF and TIF files

Post by DBr » Thu Dec 09, 2010 8:40 pm

Hi,

I have the following problem: The mouse and viewer coordinates in TIF files work fine, but when the opened file is a PDF, the resulting coordinates differ. I have a label which shows the coordinates of the mouse pointer in the document.

For example: the viewer loads a PDF with bestFit. Here I move the pointer down to the bottom and the label says, lets say, Y=500. Now, when I zoom in to double the size, I scroll down to the bottom, move the pointer over the bottom line and the label says Y=1000. As I said, this only happens on PDF files. With TIF files the label gives me always the same coordinates, no matter what zoom mode is chosen (as I think it should be).

Why are the coordinates handled differently and how can I convert them? I think there are no methods to get the coordinates in pixel for PDF.

Thanks for any help

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

Re: Different coordinates on PDF and TIF files

Post by Loïc » Fri Dec 10, 2010 7:28 pm

Hi,

PDF is a vector format with user space coordinates & TIFF a raster format with Pixel coordinates.

What I can suggest you is to use Inches coordinates according to the following formula. This will works with both image & PDF formats:

Code: Select all

Dim WidthInches As Double = GdViewer1.PageWidth / GdViewer1.HorizontalResolution
Dim HeightInches As Double = GdViewer1.PageHeight / GdViewer1.VerticalResolution
Let me know if you need more information.

Loïc

DBr
Posts: 21
Joined: Thu Dec 09, 2010 8:21 pm

Re: Different coordinates on PDF and TIF files

Post by DBr » Mon Dec 13, 2010 1:47 pm

Thanks for the help, I solved the problem.

The tricky thing was that I had to create regions based on pixel coordinates and I was a bit confused about the changing resolution. But with the DPI count of the document and your suggested formula it can be converted

Post Reply

Who is online

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