PDFpen 6 Supports Redaction via AppleScript

Philip Blog, PDFpen, PDFpen Tips

PDFpen 6 introduced support for performing redaction via AppleScript.

Redaction completely removes text from a document and leaves behind your choice of either a black box or a blank space. It can be used to remove sensitive information from a PDF before sharing it, such as names in transcripts or account numbers in bank statements.

Here's an example AppleScript showing how to remove all instances of “Smile” from the frontmost document:

tell application "PDFpen"
	tell document 1
		search string "Smile"
		repeat while performing search
			delay 0.1
		end repeat
		redact with block
		repeat while performing redaction
			delay 0.1
		end repeat
		display dialog "Done"
	end tell
end tell

The first part of the script performs a search for all instances of “Smile” in the frontmost document and waits for the search to complete.

The second part of the script tells PDFpen to redact all the instances of “Smile” found in the search, replacing them with a black block, and waiting for the redaction to complete. If you prefer blank space, use “redact without block”.

Once this script is completed, you'll no longer be able to search the document for “Smile”, because “Smile” no longer appears in the document.

You can use this sample as the basis for part of a folder action or automator action to perform redaction as part of your workflow.

Enjoy!