Author Topic: Distiller handler loaded script.  (Read 1225 times)

0 Members and 1 Guest are viewing this topic.

Offline larsen67

  • Sr. Member
  • ****
  • Posts: 459
  • Karma: 10
  • Gender: Male
Distiller handler loaded script.
« on: July 04, 2007, 11:39:42 AM »
I have several script libraries that I am at present trying to build (time permitting) starting with the things I use the most. I will post them separately as I think it will be easier to discuss this way. As I have never attempted to do this before Im uncertain as to how far to go with error trapping etc (I can't see what happens inside of handlers) here is my one for Acrobat Distiller I have tried to make the parameters as flexible as possible so that it can be called in various ways. Have I missed anything? been over zealous? going about this the wrong way? can I be more economical? (most probably) thanks.

001   property |Version Number| : 1.0 -- 21/06/07 First build.
002   --
003   property |Distiller Run Count| : 0
004   property |Distiller Last Call| : ""
005   property |Distiller Last Error| : ""
006   
007   -- Requires all 3 paths specified.
008   on ProcessFiles3(|sourcePath|, |destinationPath|, |adobePDFSettingsPath|)
009        -- Check the classes of suppiled parameters
010        if class of |destinationPath| is in {alias, string, text}
011             and class of |adobePDFSettingsPath| is in {alias, string, text} then
012             if class of |sourcePath| is list then
013                  repeat with |File Path| in |sourcePath|
014                       if class of |File Path| is in {alias, string, text} then
015                            my convertPOSIX3(|File Path|, |destinationPath|, |adobePDFSettingsPath|)
016                       else
017                            set |Distiller Last Error| to "Distiller parameters are incorrect."
018                            return false
019                       end if
020                  end repeat
021             else if class of |sourcePath| is in {alias, string, text} then
022                  my convertPOSIX3(|sourcePath|, |destinationPath|, |adobePDFSettingsPath|)
023             end if
024        else
025             set |Distiller Last Error| to "Distiller parameters are incorrect."
026             return false
027        end if
028        my scriptInfo()
029        return true
030   end ProcessFiles3
031   
032   -- Requires sourcePath specified.
033   -- Setting will be last used by user, destination will be parent of sourcePath.
034   on ProcessFiles(|sourcePath|)
035        -- Check the classes of suppiled parameters
036        if class of |sourcePath| is list then
037             repeat with |File Path| in |sourcePath|
038                  if class of |File Path| is in {alias, string, text} then
039                       my convertPOSIX(|File Path|)
040                  else
041                       set |Distiller Last Error| to "Distiller parameters are incorrect."
042                       return false
043                  end if
044             end repeat
045        else if class of |sourcePath| is in {alias, string, text} then
046             my convertPOSIX(|sourcePath|)
047        else
048             set |Distiller Last Error| to "Distiller parameters are incorrect."
049             return false
050        end if
051        my scriptInfo()
052        return true
053   end ProcessFiles
054   
055   -- Called from ProcessFiles3()
056   on convertPOSIX3(|sourcePath|, |destinationPath|, |adobePDFSettingsPath|)
057        try
058             tell application "Acrobat Distiller 7.0"
059                  Distill sourcePath POSIX path of
060                       |sourcePath| destinationPath POSIX path of
061                       |destinationPath| adobePDFSettingsPath POSIX path of
062                       |adobePDFSettingsPath|
063             end tell
064        on error
065             set |Distiller Last Error| to "convertPOSIX3 failed."
066             return false
067        end try
068   end convertPOSIX3
069   
070   -- Called from ProcessFiles()
071   on convertPOSIX(|sourcePath|)
072        try
073             tell application "Acrobat Distiller 7.0"
074                  Distill sourcePath POSIX path of |sourcePath|
075             end tell
076        on error
077             set |Distiller Last Error| to "convertPOSIX failed."
078             return false
079        end try
080   end convertPOSIX
081   
082   -- Keep a record of usage in script properties
083   on scriptInfo()
084        set |Distiller Run Count| to |Distiller Run Count| + 1
085        set |Distiller Last Call| to (current date) as text
086   end scriptInfo