I decided I did not have any hope of deciphering Yvans recommended script, so went searching for myself.
but it told me the Ruby framework did not exist, so I started pruning. Big mistake. Now heaps of errors. There’s no Ruby framework in Sierra.
I know stuff all about ObjC, but this seems as though it might point the way to something useful. Is it possible, please?
# NEW SCRIPT
set tempTiffFolder to ((path to desktop as text) & "Temporary Acrobat TIFFS")
set p to 2
do shell script "mkdir -p " & quoted form of POSIX path of tempTiffFolder
set tempTiffFolder to ((path to desktop as text) & "Temporary Acrobat TIFFS")
tell application "Finder"
set theTempList to every file of folder tempTiffFolder
move theTempList to trash
end tell
try
tell application "Adobe Acrobat"
activate
open thefile as alias
end tell
end try
try
tell application "Finder" to set my PreserveFileName to name of file (my theItem)
end try
try
#set infile to (choose file of type {"com.adobe.pdf"} with prompt "Choose source pdf file.")'s POSIX path
set infile to POSIX path of (my theItem as alias as text)
do shell script "
raise ArgumentError, \"Usage: #{File.basename($0)} pdf [out_directory]\" unless [1, 2].include? ARGV.length
infile = POSIX path of tempTiffFolder
outdir = ARGV[1] ? File.expand_path(ARGV[1]) : File.dirname(infile)
raise ArgumentError, \"No such directory: #{outdir}\" unless File.directory?(outdir)
url = ""
doc = PDFDocument.alloc.initWithURL(url)
bname = File.basename(infile).sub(/\\.pdf$/i, '')
(0 .. (doc.pageCount - 1)).each do |i|
page = doc.pageAtIndex(i)
doc1 = PDFDocument.alloc.initWithData(page.dataRepresentation)
@try {
doc1.writeToFile(\"#{outdir}/#{bname}#{i % 2 == 0 }#{i / 2 + 1}.tiff\")
@catch (NSException *exception) {
doc1.writeToFile(\"#{outdir}/#{bname}#{i % 2 == 0 }#{i / 2 + 1}.jpeg\")
}
end
EOF
"
on error errmsg number errnum
set my didItPrint to false
set end of my tempPrintingErrors to "Acrobat split Document into pages main handler subroutine"
tell application "System Events" to display dialog "printAdobeAcrobat split Document into pages main handler subroutine, error " & errmsg & return & "error number " & errnum & " p = " & p giving up after 20
end try
#
try
tell application "Adobe Acrobat"
close all docs saving no
end tell
end try