Automating PDF Find & Replace Using All-About-PDF Command Line

Imagine you arrive at work and your manager calls you into their office and tells you that they have a special task for you. You see, the law firm you work for has just landed a new client and inherited a bunch of cases; consequently they now have over 80,000 PDF documents that need to be searched for certain words and each one needs to be replaced with random words. This is going to be an ongoing task for your role going forward. 

You are probably about to have a very bad week. Or is that months?

Unless of course you download All-About-PDF and use the new Find-Replace Command Line feature. This feature allows to create a special file that contains the entire Find-Replace definition including the find-replace pairs, the location of the PDF files etc. Once defined and saved, you can then run All-About-PDF with a special command to this file and it will process all the documents in the background while you get more important things done! 

Hey the week isn’t looking so bad after all? Let’s see how this works.

First create the special (JSON) file to hold the Find-Replace definition. Have a look at the sample below for all the fields available. This file should be saved on the same PC that All-About-PDF is installed on.

{
    "fileName":"C:\\My Documents\\Reports\\*.pdf”,
    “findReplacePairs":{"Binky":"Pacifier","Trash":"Garbage","Sidewalk":"Pavement"},
    “useRegex":true,
    “pageRange":"1-3, 5-7",
    “underline":false,
    “strikethrough":false,
    “outputFolder":"C:\\My Documents\\Reports\\Processed",
    “findReplacePairsFile":"C:\\My Documents\\Automation\\FindReplaceValues.txt",
    “showResult":false,
    “fileNameSuffix":"_processed"
}

The available fields are as follows:

You may also store your Find-Replace pairs in a separate text file by using the simple format below. This file can then be referenced in the JSON file above for the findReplacePairsFile field e.g.

Trash=>Garbage
Binky=>Pacifier
Sidewalk=>Pavement
Blinker=>Indicator

To put it all together, you can use the command below to run All-About-PDF to process your files.

%programfiles%\All-About\PDF\all-about-pdf.exe /findreplacewjsonfile {the path to the json file}

A real world usage of the above:

%programfiles%\All-About\PDF\all-about-pdf.exe /findreplacewjsonfile {C:\My Documents\Automation\findreplace.json}

As you can see, this advanced feature of All-About-PDF is a great time saver in carrying out a task that would otherwise be impossible to get done manually.

To get started with processing your PDF documents, download All-About-PDF today!