🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #14551

Re: Image Catalog

#14551
From: Kari Puikkonen
Date: Wed, 28 Jan 2004 13:49
123 lines
6382 bytes
PART 2



tell application "InDesign CS" 
	activate 
	set myDocument to make document 
	tell document 1 --tell doc 1 or else this stuff sets app prefs!

		--Set the measurement units to points if they're not already set to points.  
		set horizontal measurement units of view preferences to points 
		set vertical measurement units of view preferences to points

		--Create a paragraph style for the label and other text 
		set myParagraphStyle to make paragraph style with properties {name:"Label", point size:9, applied font:"Arial", font style:"Regular", horizontal scale:75} 
		set myParagraphStyle2 to make paragraph style with properties {name:"Header", point size:18, applied font:"Arial", font style:"Regular", fill color:swatch "Paper"} 
		set myParagraphStyle2 to make paragraph style with properties {name:"PageNum", point size:9, applied font:"Arial", font style:"Regular", fill color:swatch "Paper", justification:right align} 
		set myDocumentPreferences to document preferences of myDocument 
		set myNumberOfPages to round (myNumberOfFrames / myFramesPerPage) rounding up 
		set facing pages of myDocumentPreferences to 1 
		set pages per document of myDocumentPreferences to myNumberOfPages

		tell margin preferences of every page 
			set top to "6p" 
			set bottom to "3p" 
			set left to "3p" 
			set right to "3p" 
		end tell

		set myMarginPreferences to margin preferences of page 1 of myDocument 
		set myLeftMargin to left of myMarginPreferences 
		set myRightMargin to right of myMarginPreferences 
		set myTopMargin to top of myMarginPreferences 
		set myBottomMargin to bottom of myMarginPreferences

		--above lines need to stay to set up variables for other steps 
		set myLiveWidth to (page width of myDocumentPreferences) - (myLeftMargin + myRightMargin) 
		set myLiveHeight to (page height of myDocumentPreferences) - (myTopMargin + myBottomMargin) 
		set myFrameWidth to (myLiveWidth / myNumberOfColumns) 
		set myFrameHeight to (myLiveHeight / myNumberOfRows) 
		set myPages to pages of myDocument 
		set inset spacing of text frame preferences of myDocument to "3pt" 
	end tell 
	repeat with myCounter from (count myPages) to 1 by -1 
		set myPage to item myCounter of myPages 
		repeat with myRowCounter from myNumberOfRows to 1 by -1 
			set myY1 to myTopMargin + (myFrameHeight * (myRowCounter - 1)) 
			set myY2 to myTopMargin + (myFrameHeight * myRowCounter) - 6 --6 is point space between boxes 
			repeat with myColumnCounter from myNumberOfColumns to 1 by -1 
				set myX1 to myLeftMargin + (myFrameWidth * (myColumnCounter - 1)) 
				set myX2 to myLeftMargin + (myFrameWidth * myColumnCounter) - 6 
				tell myPage 
					set myBox to make rectangle with properties {geometric bounds:{myY1, myX1, myY2 - myOffset + 1, myX2}}

					--subtract myOffset to make box not overlap text box, add +1pt to make box frames overlap and look consistent 
					set myText to make text frame with properties {geometric bounds:{myY2 - myOffset, myX1, myY2, myX2}} 
				end tell

				--setting this outside of the rest of the make box statement seems extremely bad medicin!, including in "Properties" doesnt work for some reason 
				set stroke weight of myBox to "1" 
				set stroke color of myBox to swatch "Black" of document 1 
				set stroke weight of myText to "1" 
				set stroke color of myText to swatch "Black" of document 1 
			end repeat 
		end repeat 
	end repeat 
	repeat with myCounter from 1 to myNumberOfFrames 
		set myFileName to item myCounter of fileList as string 
		set myRectangle to rectangle myCounter of myDocument 
		tell myRectangle 
			place myFileName 
		end tell

		--Position/fit the graphic in the frame 
		try 
			fit myRectangle given content to frame 
			fit myRectangle given proportionally 
			fit myRectangle given center content 
		end try

		--Add the file name to the text frame 
		tell text frame myCounter of myDocument 
			tell application "Finder" --remove this Finder tell for full path 
				set myImagesName to get name of file myFileName as string 
			end tell 
			set contents to (myImagesName as string) --change myImagesName to myFileName for full path 
			set applied paragraph style of paragraph 1 to paragraph style "Label" of myDocument 
		end tell 
	end repeat

	--make a text box and put the title in it 
	repeat with W from 1 to myNumberOfPages 
		tell page W of myDocument 
			set myBigNameTextBox to make text frame with properties {geometric bounds:{36, 36, 60, 576}, contents:myTitle, fill color:swatch "Black" of myDocument} 
		end tell 
		set applied paragraph style of paragraph 1 of myBigNameTextBox to paragraph style "Header" of myDocument 
	end repeat

	--make a text box and put the page number in it 
	repeat with W from 1 to myNumberOfPages 
		set vertical justification of text frame preferences of myDocument to bottom align 
		tell page W of myDocument 
			set myPNBox to make text frame with properties {geometric bounds:{36, 432, 60, 576}, contents:"page " & W & " of " & myNumberOfPages, fill color:swatch "None" of myDocument} 
		end tell 
		set applied paragraph style of paragraph 1 of myPNBox to paragraph style "PageNum" of myDocument 
	end repeat

	--Do cleanup, if necessary.  
	if myRemoveEmptyFrames is true then 
		tell myDocument 
			tell (every rectangle whose content type is unassigned) to delete 
			tell (every text frame whose contents is "") to delete 
		end tell 
	end if

	--Reset the measurement units  
	tell document 1 
		set horizontal measurement units of view preferences to millimeters 
		set vertical measurement units of view preferences to millimeters 
	end tell 
end tell

display dialog "Done!"
Technical Details
Message-ID: <2ccfa09e.0@webx.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!webx
References: <2ccfa09e.-1@webx.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,936257a65fbd8bca
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2004-01-28 06:08:00 PST
From: "Kari Puikkonen" <kari.puikkonen@welho.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!webx
Newsgroups: adobe.scripting.indesign
Subject: Re: Image Catalog
Message-ID: <2ccfa09e.0@webx.la2eafNXanI>
Date: Wed, 28 Jan 2004 05:49:16 -0800
References: <2ccfa09e.-1@webx.la2eafNXanI>
Lines: 146
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit