Acrobat Pro X - Save as rft. Script runs but no text file produced.

Hi All,

Trying to save a PDF to a RTF file. Grabbed some code off the forum.
http://macscripter.net/viewtopic.php?id=29650 ← Thanks StefanK

Script runs but no file is produced.

Here’s my script:

set the_file to "MacOSX:Users:matmac:Desktop:Sample.pdf"
tell application "Adobe Acrobat Pro"
	activate
	open the_file
	set New_File_Path to "MacOSX:Users:matmac:Desktop:Sample.rtf"
	save front document to file New_File_Path using conversion "com.adobe.acrobat.rtf"
	close front document
end tell

Here is the repiles from the script:

tell application “Adobe Acrobat Pro”
activate
open “MacOSX:Users:matmac:Desktop:Sample.pdf”
→ missing value
→ error number 0
save document 1 to file “MacOSX:Users:matmac:Desktop:Sample.rtf” using conversion “com.adobe.acrobat.rtf”
close document 1
end tell

I don’t understand the “–> missing value” and “–> error number 0” replies. As the pdf opens without error into Acrobat and closes without error as well.

Are the ‘save’ and ‘using conversion’ syntax correct for Adobe Acrobat X (v10.1.3)?

Thanks.

Matt.

Here’s the workaround I’m using for now.

tell application "System Events"
	tell application process "Acrobat"
		tell application "Adobe Acrobat Pro" to activate
		click the menu item "Save as Rich text" of menu 1 of menu item "Action Wizard" of the menu "File" of menu bar 1
		delay 2
		click button "Close" of window 1
	end tell
end tell

Created an Action in Acrobat to ‘Save as Rich text’. Called the Action using GUI scripting. Not elegant but works.

Hi Matt,

Maybe Stefan is busy, but you might try changing the line to:

set the_file to file "MacOSX:Users:matmac:Desktop:Sample.pdf"

This is a file specification (a reference to a file that does not exist yet. As it where, you just had the string “MacOSX:Users:matmac:Desktop:Sample.pdf”. I don’t have Acrobat pro so can’t test it.

gl,
kel

Hi Matt,

Looking at it again, you’re opening the pdf which might need a reference. Instead use alias instead of file although you should be able to use file also. But, in this line:

set New_File_Path to "MacOSX:Users:matmac:Desktop:Sample.rtf"

You might want to use the file specification:

set New_File_Path to file "MacOSX:Users:matmac:Desktop:Sample.rtf"

Also, you might want to do this out of the tell block if it doesn’t work in it.

gl,
kel

Hi Kel,

Thanks for the response.

Adding the ‘New_File_Path’ outside of the Acrobat tell results in :
‘Can’t get file’

Adding the ‘New_File_Path’ inside the tell block results in :
'The variable New_File_Path is not defined.

So neither appears to work.

Matt.

Hi Matt.

I think what Kel meant to suggest was to try using a file specifier with the ‘open’ command ” as you do with the ‘save’ command ” to see if that gets rid of the unexplained replies.

set the_file to "MacOSX:Users:matmac:Desktop:Sample.pdf"
tell application "Adobe Acrobat Pro"
	activate
	open file the_file -- NB. file specifier, not just an HFS path.
	set New_File_Path to "MacOSX:Users:matmac:Desktop:Sample.rtf"
	save front document to file New_File_Path using conversion "com.adobe.acrobat.rtf"
	close front document
end tell

I don’t have Acrobat Pro, so I’m afraid don’t know why no new file’s produced. I presume the document was opening in the first place.

the open command in Acrobat Pro X works with POSIX path, HFS path, file and alias specifier.

@Matt: I have no idea why the conversion “com.adobe.acrobat.rtf” fails

Hi Stefan,

No dramas, I have a workaround. Thanks again for all the work you do supporting Applescripters.

Cheers. Matt.