• 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: Can Acrobat PDF's be saved as single pages via Applescript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can Acrobat PDF's be saved as single pages via Applescript


  • Subject: Re: Can Acrobat PDF's be saved as single pages via Applescript
  • From: Brian Christmas <email@hidden>
  • Date: Sun, 08 Jan 2017 12:17:58 +1100

G’day again.

I decided I did not have any hope of deciphering Yvans recommended script, so went searching  for myself.

I found this…

https://discussions.apple.com/thread/6474431?start=15&tstart=0

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?

Regards

Santa



# 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


 _______________________________________________
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

References: 
 >Can Acrobat PDF's be saved as single pages via Applescript (From: Brian Christmas <email@hidden>)
 >Re: Can Acrobat PDF's be saved as single pages via Applescript (From: Yvan KOENIG <email@hidden>)

  • Prev by Date: Re: Can Acrobat PDF's be saved as single pages via Applescript
  • Next by Date: Re: Can Acrobat PDF's be saved as single pages via Applescript
  • Previous by thread: Re: Can Acrobat PDF's be saved as single pages via Applescript
  • Next by thread: Re: Can Acrobat PDF's be saved as single pages via Applescript
  • Index(es):
    • Date
    • Thread