Flatten PDFs

So, I have the following script which is supposed to open the pdf, flatten it and save and close it. While it opens the pdf and saves and closes it, it doesn’t look like it’s flattening it. All the text is editable. Complicated graphics with many pieces are still complicated graphics with many pieces.

How do I get the pdf to flatten?

--Path to PDF
tell application "Finder" to set file_path to POSIX file "/Volumes/NAS/Advertising Department/20_PUBLICATION PDFS/PetCareEvent2_18 (20)_Final_7357 copy.pdf"

--Opening & Flattening the PDF
tell application "Adobe Acrobat"
	open file_path as alias
	tell document 1
		do script "this.flattenPages();"
		
		--Saving & Closing the PDF
		save to file file_path
		close
	end tell
end tell

hI

I have had issues with “do script” and “do script file” for ages, so opted to use the “Preflight” part of Acrobat
which for me is a fantastic resource, very powerful part of acrobat I have found.

If your not sure where it is, goto edit, preflight, under the “profiles tab”, select “show all”, type “Flatten” in the find area
then select “Flatten transparency (high resolution)” then edit, from this part you can navigate your way around, make
your own custom set up etc etc, it takes a bit of getting used to but worth the mucking around, well for me it was.

so try this, it uses a built in profile in acrobat, of which you can alter to suit your own needs, or you
can create your own profile.

--Path to PDF
tell application "Finder" to set file_path to POSIX file "/Volumes/NAS/Advertising Department/20_PUBLICATION PDFS/PetCareEvent2_18 (20)_Final_7357 copy.pdf"

--Opening & Flattening the PDF
tell application "Adobe Acrobat"
	open file_path as alias
	tell document 1
		
		do script "var oProfile = Preflight.getProfileByName('Flatten transparency (high resolution)')
		this.preflight(oProfile);
		"
		--Saving & Closing the PDF
		save to file file_path
		close
	end tell
end tell

Thank You!!! :slight_smile:
That made the pdf work for the people here who were having trouble printing it. Now, I can just add it to the AppleScript that makes the pdf book. :slight_smile: