Automator / Scripting help

Hi - I have a data base on PDF (Just how it was provided to me) that I am trying to put into a Numbers spreadsheet.


The PDF is set up so that If I copy a region and then paste it into Numbers, the data actually shows is almost right in the Numbers sheet.


My Question really is:

Is there a way through Automator or Macros or some other kind of scripting that will allow me to automate this instead of Copying and pasting and then making the same corrections 400 times?



[Image Edited by Moderator to Remove Personal Information]

MacBook Pro 13", macOS 10.15

Posted on Apr 16, 2020 12:12 PM

Reply
4 replies

Apr 16, 2020 1:45 PM in response to JamesBeyersdorf

The problem with a PDF is that its formatted content appears to be visually in one location, but the internal structure of the PDF scatters this content in variable places throughout the PDF and pulls it together by references.


The short answer is no script is able to read the apparent formatted text in the PDF as you are presently doing with copy and paste. Athough Automator has an action to extract the text from the PDF, that text will be a dump of the text content, and you lose any formatting in the output plain text file. A script would be useless in a jumble of unrelated text.


One concession is that one could use an Automator Quick Action where you select the specific block of text in the PDF, and use a Quick Action to take that selected content, break it down into respective variables and then insert that data into a Numbers table. All conjecture since I have not done this.


If that PDF were sent to you as a CSV, then that format improvement could be processed by a script and the Numbers table updated appropriately.

Apr 16, 2020 1:41 PM in response to JamesBeyersdorf

The answer is - it depends :)


First off, it's going to be almost impossible to get Automator to replicate your physical actions - it will be almost impossible, for example, for Automator to know what area to select in the PDF. However, if you're OK with manually selecting it, then invoking a script to do the transfer, that might work.


Alternatively, there is an Automator Action - Extract PDF Text - that will attempt to extract the text elements of the PDF into a .txt file. Depending on the formatting of the PDF, that might be enough to get you much of the way there.


Even failing that, though, it should be possible to get Automator (or, more likely, AppleScript) to manipulate the data for you - either the selected text, or the exported PDF. However there isn't enough in your post to explain how you're manipulating the data - i.e. what do you want the end result to be?

Apr 18, 2020 5:50 AM in response to Camelot

What I have noted is a multi-column PDF (using the OPs example selection) whose text is extracted via Automator produces a text document where only one column of continously appended, plain text content exists. Also, if the observed selection is copied to the clipboard instead, that content can be shoved into an AppleScript list by individual rows, hinting that an Automator Quick Action could do the same via a Run AppleScript action that front-ends Numbers placement.


Agree with your it depends observation.

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.

Automator / Scripting help

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