Indesign - Crop placed pdf file?

[format][/format]Hi All,

Working on a script to assemble pdf pages on an Indesign page. I can create the document, place the pdf, BUT can’t crack the syntax in AS to crop the placed file.

I have tried changing both the ‘geometric bounds’ and ‘visible bounds’ properties for the placed item.

Any help appreciated. Thanks.


set mypdf to "System 10.10:sample.pdf" as alias

tell application "Adobe InDesign CS6"
	activate
	set mydoc to make new document
	tell mydoc
		tell page 1
			set myplacedfile to place mypdf
			set myplacefileprop to the properties of item 1 of myplacedfile
			set {vX, vY, vW, vH} to the visible bounds of myplacefileprop
			-- display dialog {vX, vY, vW, vH} as string giving up after 2
			set visible bounds of myplacefileprop to {vX + 10, vY, vW - 10, vH}
			set {gX, gY, gW, gH} to the geometric bounds of myplacefileprop
			-- display dialog {gX, gY, gW, gH} as string giving up after 2
			set geometric bounds of myplacefileprop to {gX + 10, gY, gW - 10, gH}
		end tell
	end tell
	
end tell

Ps. where is the control for inserting images into a post. Thanks.

Model: MacPro 6.1
AppleScript: 2.4
Browser: Safari 603.1.30
Operating System: Mac OS X (10.10)

Hi, a while ago i made this script. Maybe its what you’re looking for?

Greetz, Eric

Hi Mark,

Thanks for the response, I’m sorry I not following your formula. I understand my naming of variables for the co-ordinates is incorrect. H, W are wrong, as you pointed out these are the extremities of the rectangle at opposite to the point of origin. I’ve changed the variables to tlY, tlY, brY, brX (top left Y, top left X … etc) and now tried this :


tell application "Adobe InDesign CS6"
	activate
	set mydoc to make new document
	tell mydoc
		tell page 1
			set myplacedfile to place mypdf
			set myplacefileprop to the properties of item 1 of myplacedfile
			
			set {tlY, tlX, brY, brX} to the geometric bounds of myplacefileprop
			display dialog "DEFAULT Top Left Y :" & tlY & " Top Left X :" & tlX & " Bottom Right Y :" & brY & " Bottom Right X :" & brX
			set geometric bounds of myplacefileprop to {(tlY + 10), (tlX + 10), (brY - 10), (brX - 10)}
			display dialog "NEW Geo Bounds Top Left Y :" & tlY & " Top Left X :" & tlX & " Bottom Right Y :" & brY & " Bottom Right X :" & brX
		end tell
	end tell
	
end tell

BUT the values don’t calculate with +10 & -10

Then I tried calculating the variable outside of the set geo bound command with this …


tell application "Adobe InDesign CS6"
	activate
	set mydoc to make new document
	tell mydoc
		tell page 1
			set myplacedfile to place mypdf
			set myplacefileprop to the properties of item 1 of myplacedfile
			
			set {tlY, tlX, brY, brX} to the geometric bounds of myplacefileprop
			display dialog "DEFAULT Top Left Y :" & tlY & " Top Left X :" & tlX & " Bottom Right Y :" & brY & " Bottom Right X :" & brX
			
			set tlY to tlY + 10
			set tlX to tlX + 10
			set brY to brY + 10
			set brX to brX + 10
			display dialog tlY giving up after 1
			display dialog tlX giving up after 1
			display dialog brY giving up after 1
			display dialog brX giving up after 1
			
			set geometric bounds of myplacefileprop to {tlY, tlX, brY, brX}
			display dialog "NEW Geo Bounds Top Left Y :" & tlY & " Top Left X :" & tlX & " Bottom Right Y :" & brY & " Bottom Right X :" & brX
		end tell
	end tell
	
end tell


The numbers changed to what I require, essentially shrinking the geometry box, but this was NOT reflected on the rectangle on the indesign page. (Ie. The box was the same size)

What I missing here? Could you please demonstrate the syntax that will shrink the Placed PDF frame by 10mm (Eg) on each edge.

Thanks in Advance.

Hi Eric,

Thanks for your script, it works for changing (or setting) the page box to either trim or crop, by setting this in PDF import setting.

What I am trying to achieve is to bring 2 pages into InDesign with trims and bleed (Print ready files) then adjust the spine edges on the page boxes (or rectangles) so that they line up as a Double Page Spread.

To do this my larger script opens the separate pages in Acrobat and measures the trim boxes, so that even 2 pages with different size widths can be imposed (or laid out) in Indesign with the inside trim edges of the pages butting together.
Ie. reading as a spread.

Based on your scripts, I could change the media & bleed boxes on the 2 pages in Acrobat, but I really what to be able to control this in Indesign.

Hi, not quite sure if i understand what you mean, but is this of any help?

Kind regards, Eric

Hi. I stated that you must supply a delta, or the difference; your post #4 now indicates this is 10mm, so let’s go with that. You must also have a height and width to adjust the dimensions.

set |∆| to -10 --desired change, or delta (∆ is the Greek letter for this); a negative number will crop; a positive number will pad

tell application "Adobe InDesign CS3"'s document 1
	tell view preferences to set {horizontal measurement units, vertical measurement units} to {millimeters, millimeters} --optional, depending on existing prefs
	set {Y1, X1, y2, x2} to page item 1's geometric bounds --refer to the target rectangle
	set {theHeight, theWidth} to {y2 - Y1, x2 - X1} --given math for arriving at height and width
	set rectangle 1's geometric bounds to {Y1 - |∆|, X1 - |∆|, (Y1 + theHeight + |∆|), (X1 + theWidth + |∆|)} --given math for dimension change
end tell