tags:

views:

140

answers:

2

i am writing some code in vb.net that will be generating a pdf file. i am going to be placing text and images in the pdf file. instead of doing trial and error on positioning the text and images using the pixel coordinates, i would like to be able to know exactly the coordinates of something on a pdf file. so for example i would like to move my mouse over a pdf file and it will automatically display the pixel coordinates of where the mouse is.

question is, is there a tool in vb.net or something else that will show me example the coordinates of where my mouse is?

+1  A: 

I suspect that by the time you implement a tool to do this, you could have completed it through the trail and error method.

When I had to do this same thing (using iTextSharp like you are) I started by attempting to write text to an arbitrary position on the form, say x = 100 and y = 100. When I saw where it ended up on the PDF, I adjusted. After doing this a bit you get a sense of what coordinates the next point should be at.

TIP #1:
Remember that 0, 0 references the bottom left of your document. As these numbers increase your position goes up and to the right in the document.

TIP #2:
Think about how the content on your PDF lines up on the vertical and horizontal axes. Find these values and declare them as constants in your program and reference these constants on your code. This cuts down on the number of points you need to find and makes you program more readable.

For example, on the document I'm building is a form with text with a number of lines that runs horizontally (think common y-axis values) and boxes that line up vertically (think common x-axis values).

So I determined y-axis locations for the lines and declared them like this (in C#):

const float Line1Y = 200f;
const float Line2Y = 150f;
//etc.

I also determined the x-axis locations for the boxes and declared their x-axis values like this:

const float Column1X = 100f;
const float Column2X = 200f;
//etc.

In my code when it came time to position my elements, I referred to the constants like this:

content.SetTextMatrix(Column1X, Line1Y);
content.SetTextMatrix(Column2X, Line1Y);
content.SetTextMatrix(Column1X, Line2Y);
Jay Riggs
thank you very very much, is it possible to contact you directly?
I__
It might be best to keep the Q/A here. This way more people who are better qualified to answer your questions than me will see them and be able to critique any answers I (or anybody else) give.
Jay Riggs
+1  A: 

Acrobat professional has distance tool also you can try Enfocus PDF inspector, It also has measurement tool, both match your requirement. but both are paid software u can try trial versions. I think both are available for 30 day trial.

Learner