applescript keynote document export pdf without extensions

Hi all

I have tried to export the keynote document into pdf using the below code


export document 1 as PDF to file ((path to desktop as text) & "test.pdf")

But I got PDF without extensions, but my need is create PDF name with extension. Could anyone help me to fix this?

Hi,

Im using Big Sur OS/Monetary the above code is not working I got error.

desktop is property of Finder. For the AppleScript outside of Finder tell block use desktop folder.

path to is command of Scripting Additions, so it should be (or, it is recommended to be) outside of tell blocks as well.

Pay attention to this as well: as text in my script is outside of parentheses


set desktopHFS to (path to desktop folder) as text -- outside of tell block

tell application "Keynote"
	export document 1 as PDF to file (desktopHFS & "test2.pdf")
end tell

Now it’s working. In the created PDF there is no extension(.pdf) shown in the file name. Could any one please share your thoughts?

Put down in the Finder settings: show file extensions.