You'll need to be able to parse the PDF format. As this isn't a simple operation, I would suggest that you should consider using one of the many open source PDF libraries out there. At random, I found this
] and it seems to be a fairly stable implementation. Obviously you would need to download the library and try out your document with it to see if it's suitable or not, but that should be fairly straight forward to try out.