Indesign Script centers page in CS4 but not CS6

I have an AppleScript that I use to import PDF’s that have crop and bleed marks and then exports the trimmed PDF. All I need the script to do is import the PDF and crop at Trim Box and the export.

The script works perfectly in CS4 but in CS 5.5 and 6 The PDF’s are not centered. These are single page PDF’s

Here is the Script. Any help would be very much appreciated.

tell application “Finder”

set myFolder to (choose folder with prompt "Select the folder containing the PDFs you want to convert")
set myFiles to count every item of folder myFolder
set PDF_List to every item of folder myFolder as alias list

set folder_path to (choose folder with prompt "Select folder to Save PDF files") as string


tell application "Adobe InDesign CS6"
	activate
	set pdf_style to name of PDF export presets
	set export_style to (choose from list pdf_style with prompt "Select PDF Export Preset") as string
	
	repeat with i from 1 to myFiles
		activate
		set page number of PDF place preferences to 2
		set FormDoc to make document
		tell document preferences of FormDoc
			set {page height, page width} to {"9.25 in", "11.75 in"}
		end tell
		tell FormDoc
			try
				set LayerName to layer "Image layer" of FormDoc
			on error
				set LayerName to make layer with properties {visible:true, locked:false, name:"PDF"}
				delete layer 2
			end try
			delete color "C=100 M=0 Y=0 K=0"
			delete color "C=0 M=0 Y=100 K=0"
			delete color "C=0 M=100 Y=0 K=0"
			delete color "C=15 M=100 Y=100 K=0"
			delete color "C=75 M=5 Y=100 K=0"
			delete color "C=100 M=90 Y=10 K=0"
			
			tell FormDoc
				set the_frame to make text frame
				set the geometric bounds of the_frame to {"0 in", "0 in", "11.75 in", "9.25 in"}
				tell the_frame
					set fitting alignment of frame fitting options to center anchor
					
					set pdf_page to place (item i of PDF_List) on the_frame
					set newName to text 1 thru -5 of name of (info for item i of PDF_List)
					
					set PDF_name to folder_path & newName & "_ iPad" & ".pdf"
					tell FormDoc
						export format PDF type to PDF_name using export_style without showing options
						close FormDoc saving no
					end tell
				end tell
			end tell
		end tell
	end repeat
end tell
beep
display dialog "Your PDFs are Done" buttons {"Done"} default button 1

end tell

How come you don’t set cropbox to trimbox on Acrobat instead.?

I don’t use Acrobat because I attach another script to this that restores the RGB to the file. The file is a Print Ready PDF.

Don’t have CS6 but I script ID all the time. Why not get the size of the placed PDF, then move it to be centered? You’d get the geometric bounds of it, then either find the center point and set that in the center point of the box or adjust the geometric bounds of the placed image so it’s 100% but oriented at the upper left corner with respect to the frame. Sorry I don’t have code in my head for this but I’ve done this before and I know it works. It’s like making the size “manually” instead of whatever the placed default is.

FYI: The fitting alignments problem in CS6 is a known bug, and it’s unlikely that it will be fixed, now that Adobe has abandoned CS in pursuit of their user-unfriendly subscription scheme. You need some sort of manual workaround, such as a key object alignment or just doing the math, as Chris suggests. I suspect that the reframe command, which is discussed in the InDesign Scripting Guide, might also work, but I can’t test that theory with my version.

Hi there,

a slightly different approach, why not just place the pdf using the PDF trim box as the crop? Then you would not need to draw a rectangle and fit it e.g.:

set thefile to choose file

tell application “Adobe InDesign CS6”
activate
set FormDoc to make document

tell document preferences of FormDoc
	set {page height, page width} to {"9.25 in", "11.75 in"}
end tell

tell PDF place preferences
	set PDF crop to crop trim
end tell

tell page 1 of FormDoc
	set placedItem to place thefile
end tell
set theParent to parent of (item 1 of placedItem)

align FormDoc align distribute items theParent align option horizontal centers align distribute bounds margin bounds
align FormDoc align distribute items theParent align option vertical centers align distribute bounds margin bounds

end tell

Hope this helps,
Nik

Thank you. I’ll give the suggestions a try and let everyone know.