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
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.