Getting Started with AppleScript for Pixelmator Pro

Discuss and share Pixelmator Pro resources such as templates, mockups, and tutorials.
User avatar

2023-09-18 13:23:24

Hi, people. I'm a skilled Pixelmator Pro (PP) and Mac user and of many decades professional programmer.

I'm trying to make an AppleScript to automate PP to customize the "combine many PP pxd's into one PDF" shortcut. For a start, I'd like to be able to just write a trivial test script that opens one pxd and exports it to one PDF, and I'm not getting very far. Here's what I have:
use scripting additions

tell application "Pixelmator Pro"
	set cimg to open "/Users/myhome/Pictures/aht/token.pxd"
	export cimg to file "/Users/myhome/footok.pdf" as PDF
	close cimg without saving
end tell
The "set" works fine: the image opens. But no matter what I do, I get "error "Pixelmator Pro got an error: Can’t make missing value into type document." number -1700 from missing value to document" on either the export or the close (if I remove the export). I've tried it with and without footok.pdf existing.

Ideas? Someone who has written these scripts will surely see the problem instantly.

Thanks,
Bernie