------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2017/03/17 17:22
# dMod: 2017/03/19 15:54
# Appl: PDFpenPro
# Task: Create a new one page PDF document and save it to the Desktop (best).
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @PDFpenPro, @System_Events, @Create, @New, @Document, @Save, @Desktop
------------------------------------------------------------------------------
set savePath to (path to desktop as text) & "test.pdf"
------------------------------------------------------------------------------
# Uncomment if you want to prevent the script from overwriting ~/Desktop/test.pdf
------------------------------------------------------------------------------
# try
# alias savePath
# error "test.pdf already exists at that location!"
# on error e number n
# if n ≠ -43 then error e number n
# end try
------------------------------------------------------------------------------
touchFile(savePath) of me
tell application "PDFpenPro"
activate
set newDoc to make new document
tell newDoc
set newPage to make new page at beginning of pages
save it in file savePath
end tell
end tell
------------------------------------------------------------------------------
--» HANDLERS
------------------------------------------------------------------------------
on touchFile(filePath)
try
close access fileRef
end try
set fileRef to open for access filePath with write permission
set eof of fileRef to 0
close access fileRef
end touchFile
------------------------------------------------------------------------------