InDesign CS3 - Need help placing PDF-file in existing rectangle

Hi,

I’m fooling around with this problem for weeks now an its driving me up the wall.

This is the ‘simple’ problem:

I’ve got a bundle of single page PDF-files (advertisements) and they have to be placed on separate Indesign-files.

What I’ve made so far is een drop-applet where you drop all the PDF-files.
Then you select (for every file) the desired layout (all in a different masterpage on the base file “Advertenties.indd”.

So far so good. Now all I need to do is place the PDF-file in the rectange on the page.
I put a script-label name on that rectangle “adv_1”.

Despite all my efforts I keep on getting an error something like: “Non-valid object for this request” (translated from Dutch)

Can someone tell me how to do this.

Here is what I got so far:

on open advertenties
set my_template to “Files:B:Bohn:ntvg_inloop:templates:Advertenties.indd”

repeat with advertentie in advertenties
	
	-- display a dialog to prompt the user to select a masterpage
	set myMaster to {"B-halve illustratie liggend", "C-3/4 illustratie", "D-illustratie heel", "E-illustratie aflopend"}
	
	-- get the item the user selected from the list
	set selectedMaster to {choose from list myMaster with prompt "Selecteer een pagina:"} as text
	
	tell application "Adobe InDesign CS3"
		activate
		set myDoc to open my_template
		-- without showing window
		
		tell myDoc
			set horizontal measurement units of view preferences to millimeters
			set vertical measurement units of view preferences to millimeters
			set theRef to master spread selectedMaster
			tell page 1
				set properties to {applied master:theRef} -- apply master spread
			end tell
			
			override every rectangle of master spread selectedMaster destination page last page
			
			override every page item of master spread selectedMaster destination page last page
			
			HERE SHOULD BE THE PLACING OF THE PDF (I THINK)

		end tell
		
	end tell

Assuming that you set up template with a script label assigned to the appropriate rectangle, here I use “advertentie” for example then you should just need to add the following line to the script:

place advertentie on rectangle "advertentie" of page 1

Hi Jerome,

I’ve put the line you suggested into the script and there is the error I was talking about (“Non-valid object for this request”).

By putting dialogs all over the script I’ve determined that the error occurs when executing the place-command.

What can be the cause of this ???

I have not been able to replicate your error, but this works for me:

set advertentie to choose file
tell application "Adobe InDesign CS3"
	tell document 1
		override every rectangle of master spread 1 destination page last page
		tell page 1
			place advertentie on rectangle "advertentie"
		end tell
	end tell
end tell

First thing that you need to do is open your template file, go to the master page(s) and click on the rectangle that you want to place the ad on. Double check that it is a rectangle with graphic content. Then open the script label pallet (Window>Automation>Script Label). With the rectangle selected type in the name that you want to apply to the object. Do this for all your master pages.

I have been able to get it to error out if:

  1. There is no object with the applied label. I use the label here to ensure that I am getting the correct rectangle even if the stacking order (index) changes on the page.
  2. There are two page references in the tell statement:
		tell page 1
			place advertentie on rectangle "advertentie" of page 1
		end tell

Hi

try this

tell application "Adobe InDesign CS3"
	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

I’ve used this above to center placed artwork before, but what about if I need to place it off-center? Is there a way to have the bottom edge of the placed artwork be flush with the bottom of the rectangle?