Batching a folder of Acrobat PDF's to Open, Reduce File Size, and save

Hi Barbara, of course I am =)

Well this worked for me, so not exaclty sure (after a quick glance) while yours is failing on the first print statement. If your just printing though I’m not sure why your in a save replace window at one point ?

set theFolder to choose folder
tell application "Finder" to set thefiles to entire contents of theFolder

activate application "Adobe Acrobat 7.0 Professional"
tell application "System Events"
	tell process "Acrobat"
		repeat with aFile in thefiles
			tell application "Adobe Acrobat 7.0 Professional" to open (aFile as string)
			delay 2
			click menu item "Print..." of menu 1 of menu bar item "File" of menu bar 1
			delay 2
			click button "Print" of UI element 5 of window "Print"
			delay 5
			tell application "Adobe Acrobat 7.0 Professional" to close all docs saving "No"
		end repeat
	end tell
end tell

The interesting thing to note here though is that there is an actual print command, I looked in my notes, and it doesn’t seem to be working though for some reason on my tests. I was going to provide you with that, but upon it’s failing during testing I went back to your GUI version… Any one else have an idea why this isn’t working?

tell application "Adobe Acrobat 7.0 Professional"
	set theDoc to active doc
	print pages of theDoc first 1 last 2 PS Level 2 without shrink to fit and binary output
end tell

Hi James,

Funny, I just got home from the city, read your reply, and tried it on my machine, and it worked too ???

I think I know what it was…The person’s machine I was doing this on, probably doesn’t have the Enable GUI checkbox checked in their system preferences…I bet…
I remember that being a big issue at this client once before when someone wrote a script and the IT department had to enable that for those machines. That is most likely why it bombed…never even thought of that till you said it worked Ok, and I just tried it here and it worked…
I just left that save stuff in because I was first trying to just change the two lines that I needed and then I figured, if I got that to work, get rid of that stuff :wink:
You know…baby steps :smiley:

thanks for looking at it for me…you are a gem!!!
Let me know when I am being too much a pain…
thanks!!!

babs

/slaps forehead, duh! I totally forgot to even think of that myself. I sorta just assumed LOL

And don’t ever worry about being a pain, your not and I don’t mind helping. I learned a lot asking questions on these boards and I’m happy to be able to give back to others =)

I dig the visual … slap on the far head… :lol:
It was a good assumption…probably little to no reason to ask…

I am not really sure what made me think of that…but, the fact that I did, but a little smile on my face…It means I am starting to understand this stuff a little more every day.

I know I can’t help you with any of this stuff, but I teach the Adobe Creative Suite and Quark applications. If you ever have any questions regarding those apps, I would try to help you out…it’s the least I can do to thank you for your kindness and patience…
thanks again…
babs

You can do this to reduce the size of a pdf.
You can setup a custom quarts filter in colorsync util.
the path to the custom filter is “/Users/yourshortusername/Library/Filters/CustomFilterName.qfilter”


tell application "system events"
set shortUserName to name of current user
end tell
tell application "finder"
do shell script "/System/Library/Printers/Libraries/./quartzfilter /pathtofile/filename.pdf  /System/Library/Filters/Reduce%File%Size.qfilter /pathtofile/filename.pdf"end tell

in my experience using a quartz filter to reduce the size of a PDF has caused problems thats why I went with PDTK :slight_smile:

Hello,
Yes, I just tried it with a few different paths, and I got error messages.
So, I will stick to the other way :wink:
thanks!
barbara

It’s good to hear all is going well, we haven’t seen you around LOL

Barbra,

sorry I lost track what is the process you going through now ?

mm

Hi James,

Yeah…haven’t had the opportunity to do any more applescripting ;-(
Busy with all that Quark, Adobe and FileMAker stuff…
was supposed to take an applescript class next week, but it may be postponed till june… I’m sure once I am back into it, those scripting juices will start to flow again.

I hope you are doing well!

babs :wink:

hi mcgrailm,

I was using System events with Acrobat…
Nothing more than that…
That other stuff is way over my head :wink:
thanks
barbara

Barbara,

no, its cool I was just curious what you ended up going with. Acrobat is good to use.
However I’m sure if you took the time (if you have it to begin with) you could figure out how to do the other stuff

mm

hi mm,
ahhhhh…yes that darn time factor…always an issue…isn’t it :wink:
Someone helped me with the Acroabt script and it works great!!!
That other stuff looks really cool, but I have a long way to go with this stuff. I am front end person all the way…
This code stuff is very difficult for me. But, with the help of great folks like yourself helping people on these sites, it makes it all doable…
thanks!
babs

does anyone know how to update this script for Acrobat Professional version 8.1.2?

set theFolder to choose folder
tell application “Finder” to set theFiles to entire contents of theFolder

activate application “Adobe Acrobat 7.0 Professional”

repeat with aFile in theFiles
tell application “Adobe Acrobat 7.0 Professional” to open (aFile as string)
tell application “System Events”
tell process “Acrobat”
delay 1
click menu item “Reduce File Size…” of menu 1 of menu bar item “File” of menu bar 1
delay 1
click button “OK” of group 1 of window “Reduce File Size”
delay 2
click button “Save” of window “Save As”
delay 1
click button “Replace” of window 1
delay 15
end tell
end tell
tell application “Adobe Acrobat 7.0 Professional” to close all docs saving “No”
end repeat

I tried and it fails on the save where the dialog box asks what level of compatibility you want. Is there a reference guide anywhere to the menu items/dialog boxes as I’m guessing the line that its failing on is

click button “OK” of group 1 of window “Reduce File Size”

as the first window that comes up is Acrobat Version Compatibility, though the title of the window itself is Reduce File Size

many thanks
Glenda (scripting newbie)

Give this a try =)


set theFolder to choose folder
tell application "Finder" to set theFiles to entire contents of theFolder

activate application "Adobe Acrobat Professional"

repeat with aFile in theFiles
	tell application "Adobe Acrobat Professional" to open (aFile as Unicode text)
	
	tell application "System Events"
		tell process "Acrobat"
			delay 1
			click menu item "Reduce File Size..." of menu 1 of menu bar item "Document" of menu bar 1
			delay 1
			click button "OK" of window "Reduce File Size"
			delay 2
			click button "Save" of window "Save As"
			delay 1
			click button "Replace" of sheet 1 of window "Save As"
			delay 15
			-- handle any conversion errors
			try
				click button "OK" of window "Conversion Warnings"
			end try
		end tell
	end tell
	tell application "Adobe Acrobat Professional" to close all docs saving "No"
end repeat

As for a reference there really isn’t one. What you should do though is download Apple’s UI Element Inspector - http://www.apple.com/applescript/uiscripting/02.html

Or if you intend to do a lot of UI scripting you should really plunk down the change for PreFab’s UI Browser… even Apple recommends it - http://prefabsoftware.com/uibrowser/

thank you for that. It works, but it’s very slow and that’s on my new macPro beast as well.

I don’t intend doing any more scripting than absolutely necessary - I’m a designer and detest repetitive actions enough to investigate this scripting malarky, but I would much rather pay someone else to write the scripts I need!

In fact, I think I may actually need a flash or silverlight programmer to do what I really want to do - any takers?

Glenda

Well the reason its so slow is because of the delay… as you can see there is a 15 second delay at the end of each image. So if you don’t need that much time you can reduce that number down to something more adequate for your machine specs and the pdfs you are working with.

And in regards to your other request what are you looking to have done?

So our PDF forms are getting bloated and requiring a “save as” to reduce their file size.

I was experimenting with Colorsync on the command line, but unfortunately it appears to strip out all javascript form fields, irrespective of the filter employed- even a “do nothing” filter that simply resaves.

does anyone know of a fix for this unfortunate feature?

thanks,

Ralph

I tried this script but it prompts me an error message:-

System Events got an error:
NSReceiverEvaluationScriptError: 4

Can someone help me? Thanks!

Here is updated version for Acrobat 9

-- Updated for Acrobat 9
set theFolder to choose folder
tell application "Finder" to set theFiles to entire contents of theFolder

activate application "Adobe Acrobat Pro"

repeat with aFile in theFiles
	tell application "Adobe Acrobat Pro" to open (aFile as Unicode text)
	tell application "System Events"
		tell process "Acrobat"
			delay 1
			click menu item "Reduce File Size..." of menu 1 of menu bar item "Document" of menu bar 1
			delay 1
			click button "OK" of window "Reduce File Size"
			delay 1
			click button "Save" of window "Save As"
			delay 1
			click button "Replace" of sheet 1 of window "Save As"
			delay 15
			try
				click button "OK" of window "Conversion Warnings"
			end try
		end tell
	end tell
	tell application "Adobe Acrobat Pro" to close all docs saving "No"
end repeat