Click here to Skip to main content
15,892,293 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My purpose of this tool is: To validate whether Name and address of the PDF lies within specific coordinates(so that it does not go beyond the envelope window) . Till now i have created a tool in which user can mention left, right, bottom and top coordinates in form UI. But now user dont want to enter coordinates, they want a UI page where they can draw the rectangle instead of entering coordinates. For ex) address may be in top left, top right of the page. After User draw the rectangle on any UI, i will have to extract the pixel coordinate of rectangle and convert it to PDF units and test pdf if the address lies within the rectangle drawn by user. I have done the final part(validating the pdf). But help me with how to draw the rectangle on some UI and get its coordinates during runtime.

Thanks in Advance!

What I have tried:

I tried to open a bmp and keep 4 points and then read the pixel coordinates of the points. But each point has 4 coordinates of pixel to it. So thought i would draw a rectangle in paint. But people say we cannot read rectangle or any shapes from a bmp file.Only pixels can be read.

Thanks in Advance!
Posted
Comments
Sinisa Hajnal 1-Mar-16 3:36am    
And what is wrong with keeping four points? It is not true that each has 4 coordinates, you're reading something wrong. All you need are top-left and bottom-right points and each of these has two coordinates, x and y. Anything else is additional information you don't need (height, width, color or something else).
SivaTheCoder 1-Mar-16 4:26am    
i keep 4 points in the page using paint. And then i use Bitmap.GetPixel(x,y). Send x and y as iteration values of the page size in a for loop. A single black point is read as 4 black points by the above code.So when i keep 4 points(topleft,leftbottom,rightbottom and topright), i get 16 coordinates. But i only need 4 coordinates. .
Thanking you.
SivaTheCoder 1-Mar-16 4:34am    
As you have said, only Top left and bottom right will be necessary. i can neglect the other two points. Anyhow for these two points, the code should only give two coordinates.e.g)(5,5) and (2,2).
But Bitmap.GetPixel() is returning (5.1,5.1)(5.2,5.2)(4.9,4.9)(4.8,4.8) and for bottom right (1.8,1.8)(1.9,1.9)(2.01,2.22)(2.14,2.12) like this. I think i can select the first and last values of the returned values.That would work. But i needed more clear rectangle drawing, which would be clear to End user.
Thanking you Sinisa:)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900