You can always load the document into Photoshop and user the lineal tool to measure elements into pixels, but if you need to work with more than one document in more than one case this approach will end up severely tedious and error prone.
Photoshop do have a API as you say to enable scripting, but you can't extract elements from scripts as elements are rasterized and that information is not preserved. In illustrator however, this information is preserved and you would probably be able to extract it via script.
Using scripts with Illustrator for this is not the best approach IMO though, if you plan to do this often. You are binding your self to a platform which is locked to a machine, cannot be moved to a server and so forth. You will need a more independent solution.
As PDF is nothing but postscript (basically) you can always extract content using the Postscript language. However, it is a pretty specialized language and relatively few knows it. I won't suggest anyone go and learn it if they don't already know it.
The better approach in your case will probably be to buy a license for a wrapper-library which parse all the hard stuff for you and let you extract elements in a simple way by calling a method on it.
As PDF is print oriented so all coordinates is relative to DPI, so this is something you would need to convert in your software relative to whatever unit is used (cm, mm, inches etc.). But for this you use a very simple formula.
As you don't state development platform I cannot give any specific suggestion on such a library, but be sure, there are many options out there for most common platforms (.Net, Java, PHP and so forth). But be carefully looking for one that not only allow you to create a PDF (almost all do), but also read and parse a PDF document (fewer do).
The process itself is simple:
- Extract the element you need calling a small set of functions/methods
- Get the coordinate and size
- Calculate into pixels relative to DPI and unit used.
- Convert element into bitmap (rasterized) representation.