These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Regular Expressions

jhalmanr
Registered: Jan 9 2008
Posts: 5

I currently have a project that requires me to "blackout/zero-out" prices within a PDF document and was wondering if I would be able to use JavaScript along with regular expressions to perform the search-and-replace within the PDF document?

Thus, a text string in the pdf that is like this:

$499.95

would become

$000.00

Any takers?

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Regular Expressions can be used with Acrobat JavaScript to search for "words", but Acrobat JavaScript can not replace text in the content layer of a PDF, it can only change field contents.

George Kaiser

jhalmanr
Registered: Jan 9 2008
Posts: 5
Are you referring to Acrobat Reader or Professional? I know you cannot edit content of a PDF in Reader; however, you are able to edit content in Professional.

So, the refined question would be: is this possible in Acrobat Pro?
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
You can manually edit in Professional, but JavaScript can not be used to modify text in a pdf, only the contents of form fields.

So you could use Regular Expression within JavaScript to search for the amount text, but you could not modify the text. You could get the quads for the text and then add a field over the text, but this would not remove the information, just hide it from the innocent.

George Kaiser

jhalmanr
Registered: Jan 9 2008
Posts: 5
That might actually work! Thanks for the idea...