Can't Get MacOS Pages to Export PDF -- Ideas?

I have a script to edit a document in Pages and everything works fine until I want it to export the document as a PDF and it just... doesn't. I have it generate an ENTER keystroke and nothing happens.

Is this some sort of timing issue? Has anyone else encountered a program like Pages just not responding? And how would I solve this?

Hi @gmark, could you post your actual macro so we can take a look at it?

You can use AppleScript to export the front document in Pages as a PDF. Here's an example:

Download Macro(s): Test Export PDF from Pages.kmmacros (2.5 KB)

Macro-Image

Keyboard Maestro Export

Macro-Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.
System Information
  • macOS 10.15.7
  • Keyboard Maestro v10.2

For simplicity you need to specify the full path of the output (pdf) file in the red-coloured action so don't try to use the one I've used as an example just for testing on my system.

Hi tiffle,

I was hoping you might help me alter this macro a bit, as I have been unable to work it out. This macro correctly outputs a PDF however it gives it the name "new PDF". Is there any way to have it keep the same name or alternatively, give it today's date as the title?

Thanks!

It should give the file whatever name you set in the path in that first action -- as written that would be "Testpdf.pdf".

If you want to name the file for today's date you can change that path to include the %ICUDateTime% token, setting the format as you want. So, remembering to change the path to something that works on your machine, this:

/Volumes/Users SSD/MovedUsers/taj/Desktop/KM/%ICUDateTime%yyyy-MM-dd%.pdf

...run today would export a PDF named "2025-06-10.pdf".

You might find it easier to let KM work out the path to your Desktop, which you can do by using a ~ to mean "starting at my home folder" then applying the "Filter: Standardise Path" action to the result:

image

If you want to use the same name as the original Pages file then the easiest way is to set the path to the destination folder then add the name to that in the AppleScript:

Test Export PDF with Document Name from Pages.kmmacros (2.9 KB)

Hi Hutch,
@Nige_S has given you solutions to your question (thanks). The reason you keep getting a pdf called "Testpdf.pdf" is because you have not entered the pathname of the output file in the red-coloured action at the beginning of the macro.

To avoid this unnecessary hassle, I've modified the macro so that it outputs a pdf whose name is the same as the file currently open in Pages, but with the extension "pdf". This makes the macro much easier to use: just open your Pages document and trigger the macro to get the pdf version saved on the same path as the original file.

Here is my macro as modified for you:

Test Export PDF from Pages v2 Macro (v11.0.4)

Test Export PDF from Pages v2.kmmacros (3.4 KB)

Keyboard Maestro Export

2 Likes

Thanks!

Thanks! Best forum ever.