• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: about PDFpenPro
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: about PDFpenPro


  • Subject: Re: about PDFpenPro
  • From: Christopher Stone <email@hidden>
  • Date: Sat, 18 Mar 2017 06:10:07 -0500

Hey Yvan,

(1) It seems that close access (open for access file savePath) is faster than do shell script "touch " & quoted form of POSIX path of savePath

True.

(2) At first run I'm forced to add the instruction tell application "PDFpenPro" to activate before calling the handler.

Yeah, I've fixed this in my final script.

(3) As I never used PDFpenPro before testing your script, I used  save document 1 in file savePath  as I do most of the time.
After receiving your message, I tried to remove it and the script works well without "file".

Strange.  I need “file”, although I'm not leaving the file open as you are.

(5) When there is already a true PDF named "test.pdf", the script fails - after 1 or some run - with the error : error "Erreur dans PDFpenPro : Il est impossible d’obtenir document 1. Index non valable." number -1719 from document 1

I seem to be getting around that successfully by setting the eof of the file to 0.

So far this script is working flawlessly whether on first launch of PDFPenPro or with it running.

------------------------------------------------------------------------------

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"
    if not running then
        activate
        repeat while (path to frontmost application as Unicode text) does not contain "PDFPenPro"
            delay 0.5
        end repeat
    end if
    createOnePageBlankInPDFPenPro() of me
    delay 0.1
    save document 1 in file savePath
end tell

------------------------------------------------------------------------------
on createOnePageBlankInPDFPenPro()
    tell application "System Events" to tell process "PDFpenPro"
        set frontmost to true
        keystroke "n" using {command down}
    end tell
end createOnePageBlankInPDFPenPro
------------------------------------------------------------------------------
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
------------------------------------------------------------------------------

As always – thanks for the help.  :)

--
Take Care,
Chris

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: about PDFpenPro
      • From: Christopher Stone <email@hidden>
References: 
 >Re: about PDFpenPro (From: Christopher Stone <email@hidden>)
 >Re: about PDFpenPro (From: Yvan KOENIG <email@hidden>)

  • Prev by Date: Re: about PDFpenPro
  • Next by Date: AppleScript Application Self-Check for updates
  • Previous by thread: Re: about PDFpenPro
  • Next by thread: Re: about PDFpenPro
  • Index(es):
    • Date
    • Thread