How to use a numerical variable and a loop in automator

applescriptautomatorpreview

Since scripting is not that powerful in case of Preview.app, I am trying to find the solution with Automator. Here's the problem:

I've got a protected pdf file of 130 pages. It happens that I can't print it, but I can save it page by page as jpg file. The problem is when I save it as jpeg, it closes the original file and opens the newly created jpeg file. So the task is pretty much simple (with the proper knowledge of variables and loops).

I need to make a loop, that would open my pdf file with Preview.app, go to page number i, save the document as i&".jpg", wait a second and close Preview.app.

  1. I can't find any example of building a loop.
  2. The Russian translation is disgusting (and I am not aware of a simple way of making it English once again), which makes the task even harder.
  3. I can't find any example of using variables as a parameter of the recorded 'Type' command.

After googling for a while, it looks like the best solution for this simple task is to do that manually…

Best Answer

Intheory, s.o. could copy this or clone this file, name it document.wflow and put it inside a folder structure like this /pdfToJpeg.workflow/Contents/document.wflow and open it in Automator.

This is the structure of a .workflow file when you look at Package Content.

This workflow will ask for a file to select, extract any page as pdf, rename each file like page_01.jpg and convert it from pdf to jpg.

Please be patient, its Automator, but you can invoke it step by step from Automator.app.

This is how workflow looks like: pdfToJpg.preview