Batch Split, Rename and Protect PDF Payslip using Automator

Hi,


I am basically never written a script before and more on user of application. I am however, willing to learn about scripting (applescript) and has tried several automator method.


My current condition:


I have one pdf consist of 100+ payslips, one person per page


What I am trying to achieve:


  1. Split the multi page payslip pdf into individual pdf (one pdf for one employee)
  2. Rename the the individual pdf using the text in the pdf itself (we have name and employee ID in the pdf of the payslip)
  3. Batch protect the pdf using different password for every pdf


Using automator, I only able to do number 1.


During my time browsing for answer I encounter autosplit and automassprotect from evermap, unfortunately it is for windows (and also quite costly considering there are items to buy aside from the acrobat pro itself)


I wanted to stick with mac osx to do this and trying my best not to do it in windows. Can anybody help me on this?

MacBook Pro 16", macOS 10.15

Posted on May 6, 2020 5:30 AM

Reply

Similar questions

3 replies

May 6, 2020 11:48 AM in response to JSugiarto

I don't see this moving forward past step 1.


The trick is getting the full employee name and ID out of the individual split PDF file. To do that, one must know how that data is arranged on the PDF page. For example:


Employee Name: Jon Jones Martian  Employee ID: 12345



or


Employee Name: Jon Jones Martian
Employee ID: 12345



When you convert the PDF to a text string, the second example above is transformed into the one-line format of the first.


Next, even if we know this user data layout format, a PDF is compressed data, so you cannot just extract this content without work. Choices are to use Apple's PDFKit framework where one can work on the PDF natively as text, and match the user data content using Objective-C. That would be the fastest, but one can also tell Automator to further extract the individual PDF page content to text files, where one avoids Objective-C, but then must use regular expressions to match the user data. Then use the name and ID content to rename the corresponding PDF page. This is still difficult to support using macOS UNIX tools, as the regular expression syntax has a long learning curve.


For step 3, there are no external tools that can batch set a PDF owner,user password, or other protections without using Apple's PDFKit framework with Objective-C. Not a pretty picture either.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Batch Split, Rename and Protect PDF Payslip using Automator

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.