iosobjective-cxcodepdfcgpdf

Find location of objects in PDF iOS


I have a PDF that is structured like this:

 ________________________________________________________
|                                |                      |
| 1. This is a simple question   |  A  B  C  D  E  F  G |
|________________________________|______________________|
|                                |                      |
| 2. Another simple question     |  A  B  C  D  E  F  G |
|________________________________|______________________|

... all the way to the end of the page. 

The user fills out this question air in the app and when they are finished it needs to print out the PDF question air with the selected "A, B, C, D, E, F, G" with circle drawn around them.

I can load a PDF and add annotations to it fine but the problem is that I have no idea how to find the coordinates of "A, B, C, D, E, F, G" to draw the circle around it. Is there anyway to programmatically figure this out? My last resort would be to open it up in a UIImageView and draw all the circles there but that will cut the resolution down significantly which isn't good.


Solution

  • Well, I was not able to find an easy way to find the coordinates of "A B C.." for each question in the PDF so I,

    1. Added a transparent view
    2. Added to UISteppers, one for X and Y
    3. Added a label to view to display an (x,y)
    4. Drew a circle with UIGraphicsBeginPDFContextToData
    5. Painstakingly used the steppers to move the circle around the PDF to each "A B C.." while taking note of the coordinates.

    Definitely not the most elegant solution but programmers can't always be clever I'm afraid. Only took around and hour to finish (for 30 questions).