Indesign Place PDF

Hi

I want to use the following script to place my PDF’s (yeah I know indesign comes with a PDF place script).

tell application "Adobe InDesign CS4"
	set mySpread to spread 2 of active document
	tell mySpread
		set myRectangle to make rectangle with properties {geometric bounds:{-3, -3, 300, 210}}
		set myPlacedPDF1 to place "Macintosh HD:Test1.PDF" on myRectangle
	end tell
end tell

Can any tell me how to set the position of the PDF when it is placed in to the myRectangle? I don’t mean the position of myRectangle {-3, -3, 300, 210}

many thanks

LJ

I believe you have to define the “crop PDF” parameter of the PDF place preferences as in the 2nd part of the following script. Hope this helps.

–Script by stefcyr, tested with Acrobat 8 and InDesign CS3

tell application “Finder”
activate
set mypdf to choose file with prompt “Choose the PDF you want to place in InDesign” as string
open file mypdf using application file id “CARO”
tell application “Adobe Acrobat Professional”
activate
set b to get crop box of page 1 of active doc
set w1 to item 3 of b as integer
set w0 to item 1 of b as integer
set h1 to item 2 of b as integer
set h0 to item 4 of b as integer
set PDFheight to (h1 - h0) / 72
set PDFwidth to (w1 - w0) / 72
set pagecount to count every page of active doc
set idh to PDFheight & " i" as string
set idw to PDFwidth & " i" as string
close active doc without saving
end tell

set idpage to 1
set pdfpage to 1

tell application "Adobe InDesign CS4"
	activate
	set mydoc to make document
	tell document preferences of mydoc
		set facing pages to false
		set page width to idw
		set page height to idh
		set pages per document to pagecount
		
	end tell
	repeat pagecount times
		set page number of PDF place preferences to pdfpage
		
		--  the "crop PDF" parameter can be changed to the following: crop content/crop art/
		--crop PDF/crop trim/crop bleed/crop media/crop content/crop art/¬
		--crop PDF / crop trim / crop bleed / crop media
		
		set PDF crop of PDF place preferences to crop PDF
		
		set mypdfpage to place mypdf on page idpage of mydoc
		set idpage to idpage + 1
		set pdfpage to pdfpage + 1
	end repeat
end tell

end tell

To move the art in relation to the containing rectangle use the move command:

set xOffset to -2
set yOffset to -3
set boxBounds to {-3, -3, 300, 210}
tell application "Adobe InDesign CS3"
	activate
	set mySpread to spread 2 of active document
	tell mySpread
		set myRectangle to make rectangle with properties {geometric bounds:boxBounds}
		set myPlacedPDF1 to place alias "Macintosh HD:Users:jgantner1:Desktop:Test1.PDF" on myRectangle
		set myPlacedPDF1 to item 1 of myPlacedPDF1
		move myPlacedPDF1 by [xOffset, yOffset]
	end tell
end tell

Hi lowjackson

try this

tell application "Adobe InDesign CS4"
	set mySpread to spread 1 of active document
	tell mySpread
		set myRectangle to make rectangle with properties {geometric bounds:{-3, -3, 300, 210}}
		set _PDF to "Macintosh HD:Users:Budgie:Desktop:Test1.pdf"
		place _PDF on rectangle 1 of page 1
		fit rectangle 1 given center content --thanks to Shane Stanley
	end tell
end tell

hi all,

thanks for your help!

I think Jerome has the best solution as its works around my existing script and adds the most flexibility.

LJ