dHaserot
asked on
Regular expression search in Acrobat
I want to have a plugin developed that will use regular expressions to search PDF files and then return the quad info on the matched search. I haven't been able to find any reference in the Adobe SDK that indicates this can be done.
Anybody have any input?
Dennis
Anybody have any input?
Dennis
ASKER
KhKremer,
This is my first question to the group and your response was far more detailed than I had hoped. No I am not scared away by the response.
Though you said it is not your field of expertiese, can you estimate a rough range of cost to develope the plugin (not including the regex engine)?
Thanks very much for your response.
dHaserot
This is my first question to the group and your response was far more detailed than I had hoped. No I am not scared away by the response.
Though you said it is not your field of expertiese, can you estimate a rough range of cost to develope the plugin (not including the regex engine)?
Thanks very much for your response.
dHaserot
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It's however not a trivial task. You may be able to use Javascript (that's not my field of expertiese) that you could execute from within a plug-in. I'll however only describe how you would accomplish this with just the plug-in interface.
As you've found out, there is no reg ex interface in Acrobat. You have to provide this yourself. The hard part is getting access to the textual content of the file. This can be done by using the word finder interface:
First you create a PDWordFinder object with either PDDocCreateWordFinderEx, PDDocCreateWordFinder or PDDocCreateWordFinderUCS. With this PDWordFinder you can then call either PDWordFinderGetNthWord() to get one word after the other from the list or PDWordFinderAcquireWordLis
After you are done, you destroy the PDWordFinder again and do whatever else is necessary in cleanup.
As I said, it's not trivial, but it can be done. The problem with this solution however is that you do not get white space information. Mainly because this is not part of the PDF file to start with. If the cursor gets advanced by a tab, or by eight spaces, or by a fixed amount, the "moevto" command that you will find in the PostScript code that in turn gets converted to some PDF commands will always look the same.
The content of a PDF file does not necessarily have a one-to-one relationship with elements in your source file.
You may also run into problems with sub- or superscripts: In PDF it's just a string in a smaller font, that's positioned above or below the base line. It may not even be rendered at the same time. So Acrobat needs to make some assumptions about how text belongs together.
Is this enough to completely scare yo away from doing reg expression searches in PDF? :-)