Create Catalogue or Contact Sheet

Initially I have developed this script

I have also started to work on generating Contact Sheet (Catalogue) of images available in a folder.

But I have to develop the same for MacOSX and Quark 4.1.

I also got source code from of PhotoXpress.

Thanks to all person who is/will help me directly or indirectly.

Few below lines I have written but when I run this program I got an error.

Please Check the code and suggest me the correct code.

tell application "QuarkXPressâ„¢ 4.1" 
activate 
set templateName to (choose file with prompt "Find template.")
open templateName use doc prefs yes 
tell document 1 
set horizontal measure to points 
set vertical measure to points 
end tell 
set pageInfo to (properties of page 1 of spread 1 of document 1) as list 
set topMargin to item 14 of pageInfo as point as real 
set pageLeftMargin to item 9 of pageInfo as point as real 
set bottomMargin to item 5 of pageInfo as point as real 
set rightMargin to item 13 of pageInfo as point as real 
tell page 1 of document 1 
set pagBounds to bounds as list 
set mmaxWidth to (((item 4 of pageBounds) as point) as real) - (((item 2 of pageBounds) as point) as real) - pageLeftMargin - rightMargin 
set maxHeight to (((item 3 of pageBounds) as point) as real) - (((item 1 of pageBounds) as point) as real) - bottomMargin - topMargin 

end tell 
end tell 


After Correction

 highly appreciate any one who can even look into it. I think what I am going to it is good project for me. 

I have correct my script, but I again stuck on the next line which are in bold 

Code after correction 
set topMargin to item 14 of pageInfo 
set pageLeftMargin to item 9 of pageInfo 
set bottomMargin to item 5 of pageInfo 
set rightMargin to item 13 of pageInfo 

The lines where I againg Stuck 


set maxWidth to ((item 4 of pageBounds) - (item 2 of pageBounds)) - pageLeftMargin - rightMargin 

Prooblemm occurs with item 2
Thanks

Rajeev

A script that I used to use to do this in Quark 4.1:

property MyPrefs : {Catalog:0, MinimumWidth:887}
global TheSource, theDate
--=============================
--Handlers
--=============================
on MakeDoc(thePath, TheDoc)
	tell application "QuarkXPressâ„¢ 4.11"
		make new document at beginning with properties {automatic text box:false, bottom margin:"3p", facing pages:true, horizontal measure:points, inside margin:"3p", outside margin:"3p", page height:"66p", page width:"51p", top margin:"3p", vertical measure:points, view scale:"100%"}
		save document 1 in {thePath & TheDoc}
		tell document 1
			delete color spec "Blue"
			delete color spec "Green"
			delete color spec "Red"
		end tell
	end tell
	PageSetUp(1, 1)
end MakeDoc
--=============================
on MakePage(TheDoc)
	tell application "QuarkXPressâ„¢ 4.11"
		tell document TheDoc
			make new page at end
			set ThePage to name of result
			show page ThePage
		end tell
	end tell
	PageSetUp(TheDoc, ThePage)
	return ThePage
end MakePage
--=============================
on PageSetUp(TheDoc, ThePage)
	tell application "QuarkXPressâ„¢ 4.11"
		tell document TheDoc
			tell page ThePage
				make new text box at beginning with properties {name:"PageInfo", bounds:{"3p", "3p", "5p6", "48p"}}
				set story 1 of text box "PageInfo" to (text returned of TheSource) & return & theDate
				set size of last paragraph of story 1 of text box "PageInfo" to "8 pt"
				make new picture box at beginning with properties {name:"Image1", bounds:{"5p8", "3p", "16p8", "16p9"}}
				make new text box at beginning with properties {name:"Image1info", bounds:{"17p", "3p", "19p6", "16p9"}}
				make new picture box at beginning with properties {name:"Image2", bounds:{"5p8", "18p7.5", "16p8", "32p4.5"}}
				make new text box at beginning with properties {name:"Image2info", bounds:{"17p", "18p7.5", "19p6", "32p4.5"}}
				make new picture box at beginning with properties {name:"Image3", bounds:{"5p8", "34p3", "16p8", "48p"}}
				make new text box at beginning with properties {name:"Image3info", bounds:{"17p", "34p3", "19p6", "48p"}}
				make new picture box at beginning with properties {name:"Image4", bounds:{"20p2", "3p", "31p2", "16p9"}}
				make new text box at beginning with properties {name:"Image4info", bounds:{"31p6", "3p", "34p", "16p9"}}
				make new picture box at beginning with properties {name:"Image5", bounds:{"20p2", "18p7.5", "31p2", "32p4.5"}}
				make new text box at beginning with properties {name:"Image5info", bounds:{"31p6", "18p7.5", "34p", "32p4.5"}}
				make new picture box at beginning with properties {name:"Image6", bounds:{"20p2", "34p3", "31p2", "48p"}}
				make new text box at beginning with properties {name:"Image6info", bounds:{"31p6", "34p3", "34p", "48p"}}
				make new picture box at beginning with properties {name:"Image7", bounds:{"34p8", "3p", "45p8", "16p9"}}
				make new text box at beginning with properties {name:"Image7info", bounds:{"46p", "3p", "48p6", "16p9"}}
				make new picture box at beginning with properties {name:"Image8", bounds:{"34p8", "18p7.5", "45p8", "32p4.5"}}
				make new text box at beginning with properties {name:"Image8info", bounds:{"46p", "18p7.5", "48p6", "32p4.5"}}
				make new picture box at beginning with properties {name:"Image9", bounds:{"34p8", "34p3", "45p8", "48p"}}
				make new text box at beginning with properties {name:"Image9info", bounds:{"46p", "34p3", "48p6", "48p"}}
				make new picture box at beginning with properties {name:"Image10", bounds:{"49p2", "3p", "60p2", "16p9"}}
				make new text box at beginning with properties {name:"Image10info", bounds:{"60p6", "3p", "63p", "16p9"}}
				make new picture box at beginning with properties {name:"Image11", bounds:{"49p2", "18p7.5", "60p2", "32p4.5"}}
				make new text box at beginning with properties {name:"Image11info", bounds:{"60p6", "18p7.5", "63p", "32p4.5"}}
				make new picture box at beginning with properties {name:"Image12", bounds:{"49p2", "34p3", "60p2", "48p"}}
				make new text box at beginning with properties {name:"Image12info", bounds:{"60p6", "34p3", "63p", "48p"}}
			end tell
		end tell
	end tell
end PageSetUp
--=============================
on PlaceImages(TheDoc, ThePage, TheBoxNo, ImageInfo)
	set OldDelim to AppleScript's text item delimiters
	set AppleScript's text item delimiters to ":"
	--display dialog ImageInfo as string
	tell application "QuarkXPressâ„¢ 4.11"
		tell document TheDoc
			tell page ThePage
				set image 1 of picture box TheBoxNo to ImageInfo
				set bounds of image 1 of picture box TheBoxNo to proportional fit
				set story 1 of text box (TheBoxNo & "info") to (the last text item of ImageInfo)
				--if OnNetwork of ImageInfo is "3" then
				--	set theOffset to offset of last character of character of paragraph 2 of story 1 of text box (TheBoxNo & "info")
				--	set font of character theOffset of story 1 of text box (TheBoxNo & "info") to "Zapf Dingbats"
				--end if
				set size of every paragraph of story 1 of text box (TheBoxNo & "info") to "11 pt"
				set leading of every paragraph of story 1 of text box (TheBoxNo & "info") to "11 pt"
				set justification of every paragraph of story 1 of text box (TheBoxNo & "info") to centered
			end tell
		end tell
	end tell
	set AppleScript's text item delimiters to OldDelim
end PlaceImages
--=============================
--=============================
on BuildList(DroppedItems)
	set NewList to {}
	repeat with AnItem in DroppedItems as list
		set AnItem to AnItem as string
		if the last character of AnItem is ":" then
			tell application "Finder"
				set FileList to (files of entire contents of alias AnItem whose file type is "EPSP" or file type is "TIFF" or file type is "EPSF" as list)
			end tell
			repeat with AFile in FileList
				set AFile to AFile as string
				set NewList to NewList & AFile
			end repeat
		else
			tell application "Finder"
				if file type of alias AnItem is "EPSP" or file type of alias AnItem is "TIFF" or file type of alias AnItem is "EPSF" then set NewList to NewList & AnItem
			end tell
		end if
	end repeat
	return NewList
end BuildList
--=============================
on TruncateNum(theNum)
	set theNum to theNum as string
	set AppleScript's text item delimiters to "."
	if (count of text items of theNum) is 2 then
		set x to text item 1 of theNum
		if (count of text item 2 of theNum) > 3 then
			set y to text item 2 of theNum
			set AppleScript's text item delimiters to ""
			set y to (characters 1 through 3 of y as string)
			set theNum to (x & "." & y)
		end if
	end if
	return theNum
end TruncateNum
--=============================
on open (DroppedItems)
	set KeyModifiers to keys pressed
	if (KeyModifiers) contains "Option" then set Catalog of MyPrefs to 0
	set TheSource to display dialog "Enter the source of the files." default answer ""
	set NewPath to (choose folder with prompt "Select the folder to save the files in.") as string
	set theDate to (current date) as string
	set Catalog of MyPrefs to ((Catalog of MyPrefs) + 1)
	set TheDoc to "Catalog_" & (Catalog of MyPrefs) as string
	set ThePage to 1
	MakeDoc(NewPath, TheDoc)
	set FileList to BuildList(DroppedItems)
	set MyCounter to 0
	repeat with AFile in FileList
		set MyCounter to MyCounter + 1
		if MyCounter > 12 then
			set MyCounter to 1
			set ThePage to MakePage(TheDoc)
		end if
		--set ImageInfo to CheckImage(AFile, NewPath)
		PlaceImages(TheDoc, ThePage, ("Image" & MyCounter as string), (AFile as string))
	end repeat
	tell application "QuarkXPressâ„¢ 4.11"
		close document 1 saving yes
	end tell
end open

It has been a while since I have run this, but I seam to remember that it worked pretty well.

Hi Jerome,

Thanks for your input, but sorry to say you I am extremely busy with my own script and I want to mixup new concepts.

But as I will complete my this project I will sure check your script.

Below is my script, not completed but I want to compile and run this module. But I got some error


I have go some upstairs in my work and really I need you guys: 

See the code below my code is stuck after the red line. 

=============== 
tell application "QuarkXPressâ„¢ 4.1_XU14777929963" 
activate 
(*tell default document 1 
set horizontal measure to points 
set vertical measure to points 
set page width to "8.5\"" 
set page height to "11\"" 
set guides showing to true 
set automatic text box to false 
set view scale to fit page in window 
end tell *) 
set templateName to (choose file with prompt "Choose your template.") 
open templateName use doc prefs yes 
--open file templateName use doc prefs yes 
tell document 1 
--simplify matters by always using points 
set horizontal measure to points 
set vertical measure to points 
end tell 
set pageInfo to (properties of page 1 of spread 1 of document 1) as list 
set topMargin to item 14 of pageInfo 
set pageLeftMargin to item 9 of pageInfo 
set bottomMargin to item 5 of pageInfo 
set rightMargin to item 13 of pageInfo 
tell page 1 of document 1 
set pageBounds to bounds as list 
-- set maxWidth to ((item 4 of pageBounds) - (item 2 of pageBounds)) - pageLeftMargin - rightMargin 
-- set maxHeight to ((item 3 of pageBounds) - (item 1 of pageBounds)) - bottomMargin - topMargin 
end tell 
set myFolder to choose folder with prompt "Choose your folder containing Images" 
set layOnly to false 
set myFolderText to myFolder as text 
ignoring case 
repeat with i from 4 to length of myFolderText 
if character i of myFolderText = ":" then 
if character (i - 1) of myFolderText = "s" then 
if character (i - 2) of myFolderText = "e" then 
if character (i - 3) of myFolderText = ":" then 
set layOnly to true 
display dialog ("Only .lay files will be processed") 
end if 
end if 
end if 
end if 
end repeat 
end ignoring 
display dialog ("How many points to add to box size?") ¬ 
default answer "0" buttons {"OK"} default button 1 
set addSize to text returned of result 
set addSizePts to addSize 
set theResults to (display dialog ("Enter Job Number") ¬ 
default answer "XXX" buttons {"No ID", "OK"} default button 2) 
set textJob to text returned of theResults 
set noID to button returned of theResults 

if (noID = "No ID") then 
set colorbarHeight to 0 
set singlleImage to "Yes" 
else 
display dialog ("Enter batch identification") ¬ 
default answer "Art" buttons {"OK"} default button 1 
set textBatch to text returned of result 
display dialog ("Enter Chapter identification") ¬ 
default answer "Art" buttons {"OK"} default button 1 
set textChapter to text returned of result 
set textJobBatch to "Job:" & textJob & " Chapter:" & textChapter & " Batch:" & textBatch & "" as styled text 
display dialog ("Enter date") default answer "EPG" buttons {"OK"} default button 1 
set textDate to text returned of result 
display dialog ("Enter Client Name") default answer "EPG" buttons {"OK"} default button 1 
set textClientName to text returned of result 
set textClientName to ("Client: " & textClientName) 
display dialog ("Enter your code") default answer "IHK" buttons {"OK"} default button 1 
set textOpName to text returned of result 
set textDateOpNum to (return & "Date:" & textDate & "Operator:" & textOpName) as styled text 
display dialog ("One image/page?") buttons {"YES", "NO"} default button 2 
set singleImage to button returned of result 
end if 
copy (list folder (myFolder) without invisibles) to fileList 
set currPage to 1 
set currSpread to 1 
set spreadInfo to (properties of spread currSpread of document 1) as list 
set newPage to true 
set imageOrigin to 0 
set leftMargin to pageLeftMargin 
set columnWidth to 0 
set totalImmages to 0 
if (noID = "No ID") then 
set textBoxHeight to 0 
set barCodes to true 
else 
set textBoxHeight to 58 
set bbarCodes to true 
end if 
repeat with i from 1 to count of fileList 
set imageFile to (myFolder as text) & (item i of fileList as text) 
tell application "Finder" 
try 
set fileType to file type of imageFile 
set creatorType to creator type of file imageFile 
on error 
set fileType to "RRRR" 
end try 
end tell 
if fileType ? "fold" then --checking whether it is a folder or file 
if ((fileType = "EPSF") or (fileType = "TIFF") or (fileType = "..CT") or (fileType = "JPEG") or (fileType = "GIFF")) then 
ignoring case 
if layOnly then 
if (imageFile ends with ".lay") then 
set processFile to true 
else 
set processFile to false 
end if 
else 
if (imageFile ends with ".C") or (imageFile ends with ".M") or (imageFile ends with ".Y") or (imageFile ends with ".K") then 
set processFile to false 
else 
set processFile to true 
end if 
end if 
end ignoring 
if processFile then 
set totalImages to (totalImages + 1) 
tell page currPage of spread currSpread of document 1 
if (imageOrigin + colorbarHeight + textBoxHeight) > maxHeight then 
make picture box at begining with properties {bounds:¬ 
{topMargin + colorbarHeight + imageOrigin, leftMargin, ¬ 
topMargin + colorbarHeight + imageOrigin + 36, leftMargin + 36}, color:"None"} 
end if 
tell picture box 1 
set image 1 to alias imageFile 
set imageBounds to bounds of image 1 

end tell 
end tell 
end if 
end if 

end if 
end repeat 
end tell 


First Error Line
– set maxWidth to ((item 4 of pageBounds) - (item 2 of pageBounds)) - pageLeftMargin - rightMargin
– set maxHeight to ((item 3 of pageBounds) - (item 1 of pageBounds)) - bottomMargin - topMargin

Second Error Line
set spreadInfo to (properties of spread currSpread of document 1) as list

Please give your valuable input in my script.

Thanks
Rajeev

Macrajeev,

I don’t have Quark at home, nor Quark 4 at work. An educated guess looking at your script is that the values you are trying to add together are not the proper format, and you might need to coerce them for your equation to work properly. Try:

set topMargin to item 14 of pageInfo as real
set pageLeftMargin to item 9 of pageInfo as real
set bottomMargin to item 5 of pageInfo as real
set rightMargin to item 13 of pageInfo as real

set pageBounds to bounds
 set maxWidth to ((item 4 of pageBounds as real) - (item 2 of pageBounds as real)) - pageLeftMargin - rightMargin 
-- set maxHeight to ((item 3 of pageBounds) - (item 1 of pageBounds)) - bottomMargin - topMargin 

I also wouldn’t coerce pageInfo to a list, use it as a record and pull the values out from that, it is easier from my experience. You could use the following (or something similar, again I can’t test this and haven’t scripted Quark 4 in about a year so I’m doing it from memory):

Set DocProps to properties of document 1
set maxWidth to ((page width of DocProps as real) - (right margin of DocProps as real) - (left margin of DocProps as real))
set maxHeight to ((page height of DocProps as real) - (top margin of DocProps as real) - (bottom margin of DocProps as real))

As far as your second error I would guess that there is a value in the property that does not like being coerced to a list, again just set the variable to the record of the property and call the neccessary properties from the variable when needed.

The reason for the errors, from what I can see, is that when you set the pageInfo variable you are getting a reference to the properties and not the properties themselves. Try using the following:

tell application "QuarkXPressâ„¢ 4.11"
	tell document 1
		set horizontal measure to points
		set vertical measure to points
		tell page 1 to copy {bounds as list, left margin, right margin, top margin, bottom margin} to pageInfo
		set maxWidth to ((item 4 of item 1 of pageInfo as real) - (item 2 of item 1 of pageInfo as real)) - (item 2 of pageInfo as real) - (item 3 of pageInfo as real)
		set maxWidth to ((item 3 of item 1 of pageInfo as real) - (item 1 of item 1 of pageInfo as real)) - (item 4 of pageInfo as real) - (item 5 of pageInfo as real)
	end tell
end tell

Hi Jerome,

I have completed my programs, but this program needs to analyze by experts like you.

This is my first huge program ever I have developed for Quark using Applescript. Compilation is OK, but when I run this program it doesn’t full fill my requirement.

For Color bar: You can choose any .eps files.
Template: You can create any quark template.
Folder Image: You can choose any folder containing Images only.

See the code below:


tell application "QuarkXPressâ„¢ 4.1"
	activate
	set templateName to (choose file with prompt "Choose your template.")
	open templateName use doc prefs yes
	tell document 1
		set horizontal measure to points
		set vertical measure to points
	end tell
	set pageInfo to (properties of page 1 of spread 1 of document 1) as list
	set topMargin to top margin of pageInfo as list
	set pageLeftMargin to left margin of pageInfo as list
	set bottomMargin to bottom margin of pageInfo as list
	set rightMargin to right margin of pageInfo as list
	tell page 1 of document 1
		set pageBounds to bounds as list
		set rightMargin to get right margin as real
		set leftMargin to get left margin as real
		set topMargin to get top margin as real
		set bottomMargin to get bottom margin as real
		
		set pageWidth to get page width of document 1 as real
		set pageheight to get page height of document 1 as real
		set tot to leftMargin + rightMargin
		set totalPageWidth1 to pageWidth - rightMargin
		set totalPageHeight1 to pageheight - topMargin
		set maxWidth to totalPageWidth1 - tot
		set maxHeight to totalPageHeight1 - tot
	end tell
	tell page 1 of document 1
		make new picture box at beginning with properties {bounds:{0, 0, "1\"", "1\""}}
		tell picture box 1
			set colorbarImage to choose file with prompt "Find color bar."
			set image 1 to colorbarImage
			set colorbarBounds to bounds of image 1
			set colorbarWidth to (item 3 of colorbarBounds) - (item 1 of colorbarBounds)
			set colorbarHeight to (item 4 of colorbarBounds) - (item 2 of colorbarBounds)
		end tell
		delete picture box 1
	end tell
	set myFolder to choose folder with prompt "Choose your folder containing Images"
	set layOnly to false
	set myFolderText to myFolder as text
	ignoring case
		repeat with i from 4 to length of myFolderText
			if character i of myFolderText = ":" then
				if character (i - 1) of myFolderText = "s" then
					if character (i - 2) of myFolderText = "e" then
						if character (i - 3) of myFolderText = ":" then
							set layOnly to true
							display dialog ("Only .lay files will be processed")
						end if
					end if
				end if
			end if
		end repeat
	end ignoring
	display dialog ("How many points to add to box size?") default answer "0" buttons {"OK"} default button 1
	set addSize to text returned of result
	set addSizePts to addSize as real
	set theResults to (display dialog ("Enter Job Number") default answer "XXX" buttons {"No ID", "OK"} default button 2)
	set textJob to text returned of theResults
	set noID to button returned of theResults
	if (noID = "No ID") then
		set colorbarHeight to 0
		set singlleImage to "Yes"
	else
		display dialog ("Enter batch identification") default answer "Art" buttons {"OK"} default button 1
		set textBatch to text returned of result
		display dialog ("Enter Chapter identification") default answer "Art" buttons {"OK"} default button 1
		set textChapter to text returned of result
		set textJobBatch to "Job:" & textJob & "	Chapter:" & textChapter & "	Batch:" & textBatch & "" as styled text
		display dialog ("Enter date") default answer "EPG" buttons {"OK"} default button 1
		set textDate to text returned of result
		display dialog ("Enter Client Name") default answer "EPG" buttons {"OK"} default button 1
		set textClientName to text returned of result
		set textClientName to ("Client: " & textClientName)
		display dialog ("Enter your code") default answer "IHK" buttons {"OK"} default button 1
		set textOpName to text returned of result
		set textDateOpNum to (return & "Date:" & textDate & "Operator:" & textOpName) as styled text
		display dialog ("One image/page?") buttons {"YES", "NO"} default button 2
		set singleImage to button returned of result
	end if
	copy (list folder (myFolder) without invisibles) to fileList
	set currPage to 1
	set currSpread to 1
	set spreadInfo to (properties of spread currSpread of document 1) as list
	set newPage to true
	set imageOrigin to 0
	--	set leftMargin to leftMargin
	set columnWidth to 0
	set totalImages to 0
	if (noID = "No ID") then
		set textBoxHeight to 0
		set barCodes to true
	else
		set textBoxHeight to 58
		set barCodes to true
	end if
	repeat with i from 1 to count of fileList
		set imageFile to (myFolder as text) & (item i of fileList as text)
		tell application "Finder"
			try
				set fileType to file type of imageFile
				set creatorType to creator type of file imageFile
			on error
				set fileType to "RRRR"
			end try
		end tell
		if fileType ≠ "fold" then --checking whether it is a folder or file
			if ((fileType = "EPSF") or (fileType = "TIFF") or (fileType = "..CT") or (fileType = "JPEG") or (fileType = "GIFF")) then
				ignoring case
					if layOnly then
						if (imageFile ends with ".lay") then
							set processFile to true
						else
							set processFile to false
						end if
					else
						if (imageFile ends with ".C") or (imageFile ends with ".M") or (imageFile ends with ".Y") or (imageFile ends with ".K") then
							set processFile to false
						else
							set processFile to true
						end if
					end if
				end ignoring
				if processFile then
					set totalImages to (totalImages + 1)
					tell page currPage of spread currSpread of document 1
						if (imageOrigin + colorbarHeight + textBoxHeight) > maxHeight then
							make picture box at begining with properties {bounds:¬
								{topMargin + colorbarHeight + imageOrigin, leftMargin, ¬
									topMargin + colorbarHeight + imageOrigin + 36, leftMargin + 36}, color:"None"}
						end if
						tell picture box 1
							set image 1 to alias imageFile
							set imageBounds to bounds of image 1
							set imageWidth to (item 3 of imageBounds) - (item 1 of imageBounds) + addSize
							set imageHeight to (item 4 of imageBounds) - (item 2 of limageBounds) + addSize
							set saveImageHeight to imageHeight
							set saveImageWidth to imageWidth
							if imageWidth < colorbarWidth then
								set imageWidth to colorbarWidth
							end if
						end tell
						if newPage = false then
							ignoring case
								if singleImage = "Yes" then
									set leftMargin to (maxWidth + 1)
									set imageOrigin to (maxHeight + 1)
								end if
							end ignoring
							if (leftMargin + imageWidth) > maxWidth then
								set leftMargin to (maxWidth + 1)
								set imageOrigin to (maxHeight + 1)
							end if
							if (imagOrigin + colorbarHeight + imageHeight + textBoxHeight) > maxHeight then
								delete picture box 1
								set imageOrigin to 0
								set newPage to true
								set leftMargin to (leftMargin + columnWidth + 24)
								set columnWidth to 0
								if (leftMargin + imageWidth) > maxWidth then
									set currPage to currPage + 1
									if currPage > (item 6 of spreadInfo) then
										set currSpread to currSpread + 1
										set currPage to 1
										tell document 1
											make new spread at end
											show spread currSpread
										end tell
										set leftMargin to pageLeftMargin
									end if
								end if
							end if
						else
							set newPage to false
						end if
					end tell
					set fullSize to true
					tell page currPage of spread currSpread of document 1
						if newPage = true then
							set fullImageHeight to imageHeight
							set fullImageWidth to imageWidth
							if (imageHeight > (maxHeight - (colorbarHeight + textBoxHeight))) then
								set imagHeight to (maxHeight - (colorbarHeight + textBoxHeight))
								set fullSize to false
							end if
							if (imageWidth > maxWidth) then
								set imagWidth to maxWidth
								set fullSize to false
							end if
							make picture box at beginning with properties {bounds:¬
								{topMargin + colorbarHeight + imageOrigin, leftMargin, ¬
									topMargin + colorbarHeight + imageOrigin ¬
									+ 36, leftMargin + 36}, color:"None"}
							tell picture box 1
								set image 1 to alias imagFile
								set imageBounds to bounds of image 1
								set colunWidth to imageWidth
							end tell
							set newPage to false
						end if
						tell picture box 1
							set height of bounds to imageHeight
							set width of bounds to imageWidth
							set bounds of image 1 to «constant JUSTcent»
							set boxBounds to bounds as list --box bounds reads as {A,B,C,D}
							set BoxA to ((item 1 of boxBounds) as point units) as real --converts everything to points
							set BoxB to ((item 2 of boxBounds) as point units) as real
							set BoxC to ((item 3 of boxBounds) as point units) as real
							set BoxD to ((item 4 of boxBounds) as point units) as real
							
							if (noID ≠ "No ID") then
								--set imageName to (name of image 1) as text
								get file path of image 1 --gets the path name of the imported image
								set pathName to result as text --converts the path name from a reference to text
								set oldDelims to text item delimiters of AppleScript --puts the current delimiters into a placeholder
								set text item delimiters of AppleScript to {":"} --uses the colon as the new delimiter
								set fileName to last text item of pathName --asks for the last item of the delimited text string and sets it to variable
								set text item delimiters of AppleScript to oldDelims --resets the old delimiters
								(* if the operator enters "none" for the bar code, don't ask for any more bar codes *)
								if barCodes then
									display dialog ("Enter bar code for image " & fileName) ¬
										default answer "none" buttons {"OK"} default button "OK"
									set textBarCode to text returned of result
									if (textBarCode = "none") or (textBarCode = "NONE") or (textBarCode = "None") then
										set textBarCode to ""
										set barCodes to false
										(* set textBoxHeight to 36 *)
									else
										if textBarCode ≠ "" then
											(* set textBarCode to (return & "Bar Code: " & textBarCode) as styled text *)
											set textBarCode to (" Bar Code: " & textBarCode)
										end if
									end if
								else
									set textBarCode to ""
								end if
								
								if (creatorType = "ART5") then
									set textCreator to " Creator: Illustrator"
								else if (creatorType = "8BIM") then
									set textCreator to " Creator: PhotoShop"
								else if (creatorType = "FH40") then
									set textCreator to " Creator: FreeHand"
								else
									set textCreator to " CreatorID: " & creatorType as text
								end if
								--set textClientBarCode to (return & textClientName & textBarCode) as styled text
								set textClientBarCode to (return & textClientName & textBarCode & textCreator) as styled text
								if fullSize then
									set sizeDisclaimer to ""
								else
									set sizeDisclaimer to " (complete image is not displayed; full size=" & (saveImageWidth as text) ¬
										& " x " & (saveImageHeight as text) & ")"
								end if
							end if
							
						end tell
						if (noID ≠ "No ID") then
							set textIDSize to (return & "Fig: " & fileName & " Size: " & (saveImageWidth as text) ¬
								& " X" & (saveImageHeight as text)) as styled text
							(* add a box identifying the figure including job, batch, client, barcode, name, size, date and oper *)
							make new text box at beginning with properties ¬
								{bounds:{BoxC + 6, BoxB, BoxC + 6 + textBoxHeight, BoxD}, runaround:none runaround, color:"None"} ¬
									
							if sizeDisclaimer ≠ "" then
								set story 1 of text box 1 to (fileName & sizeDisclaimer) as styled text
							else
								set story 1 of text box 1 to (textJobBatch & textClientBarCode & textIDSize & textDateOpNum) as styled text
							end if
							set justification of story 1 of text box 1 to «constant JUSTcent»
							if sizeDisclaimer = "" then
								tell paragraph 1 of story 1 of text box 1
									(* if (word count) = 2 then *)
									(*	set style of word 1 to bold *)
									(*	set style of word 2 to italic *)
									(* else *)
									set style of word 1 to «constant Stylbold»
									(* word 3 *)
									--select character 1
									(*set textArray to words as list
									set arrayLength to length of textArray
									repeat with i from 1 to arrayLength
									*)
									set paraLength to count of words
									repeat with i from 1 to paraLength
										if word i = "Batch" then
											set style of word i to «constant Stylbold»
										else if word i = "Chapter" then
											set style of word i to «constant Stylbold»
										end if
									end repeat
									(* end if *)
								end tell
								(* if textBarCode ≠ "" then *)
								tell paragraph 2 of story 1 of text box 1
									set style of word 1 to «constant Stylbold»
									set paraLength to count of words
									if textBarCode ≠ "" then
										(* set style of words 1 through 2 to bold *)
										(* word count *)
										repeat with i from 1 to paraLength
											if word i = "Bar" then
												set style of words i thru (i + 1) to ¬
													«constant Stylbold»
											end if
										end repeat
									end if
									repeat with i from 1 to paraLength
										if word i = "Creator" then
											set style of word i to «constant Stylbold»
										else if word i = "CreatorID" then
											set style of word i to «constant Stylbold»
										end if
									end repeat
								end tell
								(* end if *)
								tell paragraph 3 of story 1 of text box 1
									set style of word 1 to «constant Stylbold»
									(* word count *)
									set paraLength to count of words
									repeat with i from 1 to paraLength
										if word i = "Size" then
											set style of word i to «constant Stylbold»
										end if
									end repeat
								end tell
								tell paragraph 4 of story 1 of text box 1
									set style of word 1 to «constant Stylbold»
									set paraLength to count of words
									repeat with i from 1 to paraLength
										if word i = "Oper" then
											set style of word i to «constant Stylbold»
										end if
									end repeat
									(* word count *)
								end tell
								tell text box 1
									show
									set heightAdjustment to 6
									set item3 to (BoxC + 6 + textBoxHeight + heightAdjustment)
									--repeat while box overflows and (item3 < maxHeight)
									repeat while box overflows
										--if box overflows then
										set bounds to {BoxC + 6, BoxB, item3, BoxD}
										set heightAdjustment to heightAdjustment + 6
										set item3 to (BoxC + 6 + textBoxHeight + heightAdjustment)
										--end if
									end repeat
								end tell
							end if
						end if
						if (noID ≠ "No ID") then
							
							(* add the color bar *)
							make picture box at beginning with properties ¬
								{bounds:{BoxA - colorbarHeight - 1, BoxB, BoxA - 1, BoxB + colorbarWidth}, color:"None"}
							tell picture box 1
								set image 1 to colorbarImage
							end tell
							set imageOrigin to BoxC + textBoxHeight -- starting point of next image
							if imageWidth > columnWidth then
								set columnWidth to imageWidth
							end if
						end if
					end tell
				end if
			end if
		end if
	end repeat
	display dialog (totalImages as text) & " images processed in " & myFolder & ". " buttons {"OK"} default button {"OK"}
	tell document 1
		show page -1 --last page
	end tell
end tell

I am very eager to see the out put of this program.

My next task is to generating pdf of this template. This is only Beta Version.

I will really thanks every one who can show even minor interest in this program.

Thanks & Rajeev
Rajeev Kumar

Hi Jermone & all,

I found my errors and the error line is:

repeat with i from 1 to count of fileList

How can I take count of fileList as real/integer so that it will work.

Thanks
Rajeev

Hi Jerome

I think you have a short of time so you have not reply me yet.

I am getting a problem in my script when checking:

		if (fileType = "EPSF") or (fileType = "TIFF") or (fileType = "..CT") or (fileType = "JPEG") or (fileType = "GIFF") then
			display dialog "HI"
			
		end if

Please look in to my code.

I try to compile your code it shows error for the following line

	set KeyModifiers to keys pressed

pressed

Thanks
Rajeev

Macrajeev,
I’ve been away from my computer due to vacation/holidays. It’s been so long since I ran that script that I forgot that it used Jon’s comands to capture modifier keys when the script was run so that it could reset some preferences. If you comment out the following lines, or download the OSAX and load it in the scripting addition’s folder then it should compile.

set KeyModifiers to keys pressed
if (KeyModifiers) contains "Option" then set Catalog of MyPrefs to 0

As to your problem with the file list count, it works fine for me when I isolate the lines, I don’t have Quark 4.1 anymore so I can’t compile your full script to test it.

Looking at your code, I would be tempted to have the finder only grab the files that you are iinterested in.

tell application "Finder" to set fileList to (files of entire contents of myFolder whose file type is "EPSP" or file type is "TIFF" or file type is "EPSF" or file type is "JPEG" or file type is "GIFF" or file type is "..CT" as list)

Should work for this, and you could streamline your script since it gives you a list of file references instead of just the file names. You might also be running into problems with refering to files as strings vs. file references. You may need to coerce them appropriatly for some of your lines of code to work. In particular I think you need to change these lines to the “Finder” to read:

set fileType to file type of alias imageFile
set creatorType to creator type of alias imageFile

You could streamline your finder calls to the following:

try
	tell application "Finder" to copy {file type of imageFile, creator type of imageFile} to {fileType, creatorType}
on error
	copy {"RRRR", ""} to {fileType, creatorType}
end try

Again, be aware of when you the variable for the file is a string and when it is an alias and coerce it as neccessary, I think that this may be causing some of your problems.

I hope this helps. I would like to look into your code more, but it is hard without the neccessary programs. I would suggest that you might try using some handlers to simplify your code and make it easier to reuse the code in other scripts.

Hi Jrome,

Thanks a lot. Since I didn’t get any response from your side, so I slightely change my code and it comiled successfully. But I am getting some problem in getting picture box bounds as real or points.

						tell picture box 1
							(* set size of box to the size of the image *)
							set height of bounds to imageHeight
							set width of bounds to imageWidth
							--							get bounds of image 1 as list
							set bounds of image 1 to «constant JUSTcent»
							set boxBounds to get bounds as real --or list							set BoxA to get item 1 of boxBounds as real  							set BoxB to get item 2 of boxBounds as real
							set BoxC to get item 3 of boxBounds as real
							set BoxD to get item 4 of boxBounds as real

Later on I am using this code


							make new text box at beginning with properties ¬
								{bounds:{BoxC + 6, BoxB, BoxC + 6 + textBoxHeight, BoxD}, runaround:none runaround, color:"None"} ¬


since BoxC is not in real so I am not able to calculate BoxC+6.

Please check it, if possible for you.

And I have also downloaded OSAX, but what to do next. I double click over it and ask for application. How can I install it or I should keep it in the Preferences folder.

Thanks
Rajeev

I’ll look at the code a little later today and see if I can find any probems.

As for the script that I posted earlier all you need to do is drop a folder of images or some images on the script and it should process those images.

Hi Jerome,

Do you have any yahoo/hotmail/gmail or any ID.

I have saved your program and dropped the folder containing images. But below lines give error


set KeyModifiers to keys pressed
if (KeyModifiers) contains "Option" then set Catalog of MyPrefs to 0

I have also downloaded OSAX, but where I have to put or what I have to do it with OSAX.

Thanks
Rajeev

Hi Jerome,

I have streched myself till, while my office is closed at 6:00 P.M. (IST). But I am still in the office it is now 10:30 PM (IST).

I think that I will share some your knowledge, but I am badluck guy, you have logged in only once.

Thanks

Rajeev