Re: Saving PDF as RTF in Adobe Acrobat
Re: Saving PDF as RTF in Adobe Acrobat
- Subject: Re: Saving PDF as RTF in Adobe Acrobat
- From: Denis Boyd <email@hidden>
- Date: Fri, 14 Aug 2015 14:43:29 +0100
I've done some more research and now I have this script which doesn't
generate any errors but doesn't produce any rtf files. if i change
"com.adobe.acrobat.rtf" to "com.adobe.acrobat.plain-text" it generates
plain text files successfully.
Does anyone know a way to make this work or is the scripting just broken
in Adobe Acrobat Pro DC?
Applescript 2.4
OS X 10.10.1
MacBookPro 2.3 GHz Intel Core i7
on run
set pdf_list to {}
set pdf_list to getfiles("PDF", "Choose the PDFs")
repeat with i from 1 to length of pdf_list
set current_file to item i of pdf_list as alias
set folder_path to get_folder_path_from_file_alias(current_file)
tell application "Finder"
set pdf_file_name to name of current_file
end tell
set new_file_name to
get_short_file_name_from_alias(current_file) & ".rtf" as string
tell application "Adobe Acrobat"
activate
open current_file as alias
save front document to file (folder_path & ":" &
new_file_name) using conversion "com.adobe.acrobat.rtf"
close document pdf_file_name
end tell
end repeat
end run
--Handlers below
on getfiles(requiredFileExt, promptForFiles)
set newFileList to {}
tell application "Finder"
activate
set baseFileList to choose file with prompt ¬
promptForFiles ¬
multiple selections allowed true as list
repeat with i from 1 to length of baseFileList
set theItemInfo to the info for (item i of baseFileList)
set fileExt to the name extension of theItemInfo
--display dialog fileExt & " " & length of baseFileList
ignoring case
if requiredFileExt = fileExt then
copy item i of baseFileList to the end of newFileList
end if
end ignoring
end repeat
end tell
return newFileList
end getfiles
on get_short_file_name_from_alias(fileAlias) -- returns the short file
name from an alias to a file (ie without the file extension)
tell application "Finder"
set longFileName to name of fileAlias
set fileExtension to name extension of fileAlias
set x to length of fileExtension
set y to (length of longFileName) - (x + 1)
set shortFileName to (characters 1 through y of longFileName)
as string
return shortFileName
end tell
end get_short_file_name_from_alias
on get_folder_path_from_file_alias(fileAlias)
tell application "Finder"
set oldtid to AppleScript's text item delimiters
set fileName to name of fileAlias
set AppleScript's text item delimiters to {":"}
set full_path to fileAlias as string
set full_path to full_path's text items
set AppleScript's text item delimiters to oldtid
set thePath to item 1 of full_path's text items
repeat with i from 2 to (count of full_path's text item) - 1
set thePath to thePath & ":" & item i of full_path's text items
end repeat
end tell
return thePath
end get_folder_path_from_file_alias
On 14/08/2015 13:42, Denis Boyd wrote:
Hello all,
I am trying to write a simple script to batch convert some PDF files
to RTF or DOCX using Adobe Acrobat.
Acrobat's AppleScript dictionary isn't very helpful:
save v : Save the document.
save specifier : The document to be saved.
[to alias] : An “alias” or “file” path of the new document (Save As...).
[using specifier] : Conversion class object to use. Converts to
non-PDF formats.
[linearize boolean] : Whether the document should be saved as linearized.
Does anyone know what the names of the 'Conversion classes' are and
what the syntax is for using them?
currently I have:
tell application "Adobe Acrobat"
activate
open current_file
save document pdf_file_name to folder_path & ":" &
new_file_name using [Conversion class]
close document new_file_name
end tell
Thanks in advance for any suggestions.
Denis
_______________________________________________
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