Copy link to clipboard
Copied
I have a line in my applescript to set a text box at a certain area on the document.
Is it possible to set it so that it starts the box point in the lower left of the page?
I am trying to either get it to NOT go off the bottom of the page
OR
Just set all 4 corners at a specific location on the page.
Page sizes can vary.
set slugText to make new text frame with properties {geometric bounds:{(item 4 of page 1's bounds), 0.25, ((item 1 of page 1's bounds) + 1.5), 2}, stroke color:"noprint", stroke weight:1, item layer:"Job Info - Non-Print"}
Try this—note you have not set your rulers in the script so this wont work if they are set to anything other than inches:
tell application id "com.adobe.indesign"
tell active document
set zero point to {0, 0}
delete unused swatches
set allSwatches to every swatch
try
set noprint to make color with properties {model:spot, space:CMYK, color value:{100, 0, 0, 0}, name:"noprint"}
on error
set noprint to every color whose name is "noprint"
end try
try
wb to make color w
...
You would have to set up else if statements for the different endings:
repeat with x in allSwatches
set sn to name of x
if word 1 of sn is "PANTONE" and last character of sn is "C" then
set sn to text 1 thru -2 of sn
else if word 1 of sn is "PANTONE" and text -2 thru -1 of sn is "UP" then
set sn to text 1 thru -3 of sn
else if word 1 of sn is "PANTONE" and text -2 thru -1 of sn is "CP" then
set sn to text 1 thru -3 of sn
end if
if sn is not in ds then
set ul
...
Copy link to clipboard
Copied
Hi @denisep726548, I'm not very skilled in applescript, but see if this helps:
tell application "Adobe InDesign 2022"
set doc to active document
set page1 to page 1 of doc
tell page1 to set slugText to make new text frame with properties {layer:layer "Job Info - Non-Print" of doc}
set textFrameHeight to 1.5
set leftMargin to 0.5
set rightMargin to 0.5
set bottomMargin to 0.25
tell slugText
set geometric bounds to {(item 3 of bounds of page1) - textFrameHeight - bottomMargin, leftMargin, (item 3 of bounds of page1) - bottomMargin, (item 4 of bounds of page1) - rightMargin}
set stroke color to "noprint"
set stroke weight to 1
end tell
end tell
- Mark
Copy link to clipboard
Copied
Is it possible to set it so that it starts the box point in the lower left of the page?
Hi @denisep726548 , Marks’s script is placing the frame to the lower left margin, this would make a 2" x 1" frame placed in the lower left corner. Also, when setting dimensions you’ll need to set the scripting units or ruler units, otherwise the document’s current ruler units will determine what 144 means.
tell application id "com.adobe.indesign"
set measurement unit of script preferences to points
tell active document
tell page 1
set y to item 3 of bounds
set fw to 144
set fh to 72
set slugText to make new text frame with properties {geometric bounds:{y - fh, 0, y, fw}, stroke color:"Black", stroke weight:1}
end tell
end tell
end tell
Copy link to clipboard
Copied
Also, if you want to fit the constructed text frame into the actual document slug
tell application id "com.adobe.indesign"
set measurement unit of script preferences to points
tell active document
--set the bottom slug dimension to 1"
set slug bottom offset of document preferences to 72
--get the document's bottom bleed
set bo to document bleed bottom offset of document preferences
--the frame’s height
set fh to slug bottom offset of document preferences
tell page 1
--the top of the text frame
set y to (item 3 of bounds) + bo
--the width of the text frame
set fw to (item 4 of bounds) * 0.5
set slugText to make new text frame with properties {geometric bounds:{y, 0, y + fh - bo, fw}, stroke color:"Black", stroke weight:1}
end tell
end tell
end tell
Copy link to clipboard
Copied
I actually need Mark's script to do what it is doing, but just make the box a certain width, rather than a negative number away from the right margin. Like tell it to be 2" wide all the time.
I DO want it on the page rather than in the slug area. I think I need a combo of what you both said.
Copy link to clipboard
Copied
Here is my entire script
tell application "Adobe InDesign 2022"
tell the active document
delete unused swatches
set allSwatches to every swatch
try
set noprint to make color with properties {model:spot, space:CMYK, color value:{100, 0, 0, 0}, name:"noprint"}
on error
set noprint to every color whose name is "noprint"
end try
try
wb to make color with properties {model:spot, space:CMYK, color value:{0, 0, 0, 100}, name:"wb"}
on error
set wb to every color whose name is "wb"
end try
try
set infoLayer to make layer with properties {name:"Job Info - Non-Print", printable:true, layer color:blue}
on error
set infoLayer to every layer whose name is "Job Info - Non-Print"
end try
set ul to return & "Ink Color(s):" & return
set ds to {"None", "Registration", "Paper", "noprint", "wb", "die", "white"}
delete every page item of item 1 of infoLayer
repeat with x in allSwatches
if name of x is not in ds then
set ul to ul & name of x & return
end if
end repeat
set slugText to make new text frame with properties {geometric bounds:{(item 4 of page 1's bounds), 0.25, ((item 1 of page 1's bounds) + 1.5), 2}, stroke color:"noprint", stroke weight:1, item layer:"Job Info - Non-Print"}
set contents of slugText to ul
set contents of slugText to ul
set fill color of text 1 of slugText to "noprint"
set overprint fill of text 1 of slugText to true
set applied font of text 1 of slugText to "Helvetica LT Std"
set font style of text 1 of slugText to "Condensed"
set first line indent of text 1 of slugText to 0.125
set overprint stroke of slugText to true
set Text_Frame to item 1 of (every text frame whose label is "slugText")
tell slugText
set theLines to every line
--get maxLineLength
set maxLength to null
repeat with i from 1 to count of theLines
set {start, stopp} to {horizontal offset of line i, end horizontal offset of line i}
set currentLineLength to stopp - start
if i is 1 then
set maxLength to currentLineLength
else
if currentLineLength is greater than maxLength then
set maxLength to currentLineLength
end if
end if
end repeat
--set x2-bounds of Text_Frame
set {y1, x1, y2, x2} to visible bounds
set visible bounds to {y1, x1, y2, x1 + maxLength + 0.25}
--fit height
fit given frame to content
end tell
end tell
end tell
Copy link to clipboard
Copied
....and I would like the end result to look something like this, but the lower left corner of the text box stays in place and will flex as more lines are added to it.
Copy link to clipboard
Copied
The bounds array is {Y1(top), X1(left), Y2(bottom), X2(right)} relative to the rulers zero point (normally the upper left corner of the page, unless it’s been changed). So a 2" width is {Y1, X1, Y2, X1+2}, assuming the rulers are set to inches.
Why isn‘t your printer just running a preflight, both InDesign’s and AcrobatPro’s preflights will report document ink colors. If you Package from ID, the Package Info also lists used ink colors.
Copy link to clipboard
Copied
Thank you! I changed this {y1, x1, y2, x1 + maxLength + 0.25} to {y1, x1, y2, x1 + 2} and it works as I would like it to.
We are the printer and are putting the info on our proof for the CSR and Customer. Doing a preflight report does not make sense in this case for our purpose in prepress. Thank you.
Copy link to clipboard
Copied
What would happen if the client’s using the Color Picker and all the page colors are unnamed?
Copy link to clipboard
Copied
That would never happen for us. We do all the file prep and ensure all the color seps are correct before printing.
Copy link to clipboard
Copied
So does anyone know how to have it read the bottom of the text frame (after I fit it to the text line height) and move it back to .25 from the bottom margin?
Copy link to clipboard
Copied
Try this—note you have not set your rulers in the script so this wont work if they are set to anything other than inches:
tell application id "com.adobe.indesign"
tell active document
set zero point to {0, 0}
delete unused swatches
set allSwatches to every swatch
try
set noprint to make color with properties {model:spot, space:CMYK, color value:{100, 0, 0, 0}, name:"noprint"}
on error
set noprint to every color whose name is "noprint"
end try
try
wb to make color with properties {model:spot, space:CMYK, color value:{0, 0, 0, 100}, name:"wb"}
on error
set wb to every color whose name is "wb"
end try
try
set infoLayer to make layer with properties {name:"Job Info - Non-Print", printable:true, layer color:blue}
on error
set infoLayer to every layer whose name is "Job Info - Non-Print"
end try
set ul to return & "Ink Color(s):" & return
set ds to {"None", "Registration", "Paper", "noprint", "wb", "die", "white"}
delete every page item of item 1 of infoLayer
repeat with x in allSwatches
if name of x is not in ds then
set ul to ul & name of x & return
end if
end repeat
tell page 1
set os to 0.25
set {a, b, c, d} to bounds
--makes the text frame with an initial bounds set to the the page dimensions with the list as the contents
set slugText to make new text frame with properties {geometric bounds:{a, os, c, d}, stroke color:"noprint", stroke weight:1, item layer:"Job Info - Non-Print", contents:ul}
tell slugText
--fits the text frame to the contents
fit given frame to content
--set the properties of the text
set properties of text 1 to {fill color:"noprint", overprint fill:true, first line indent:os * 0.5, applied font:"Helvetica LT Std", font style:"Condensed"}
--get the frame’s adjusted bounds
set {e, f, g, h} to geometric bounds
--the frame’s height
set h to (g - e) + os
--get the longest line
set ho to 0
repeat with z in lines
if horizontal offset of last character of z is greater than ho then
set w to horizontal offset of last character of z
end if
set ho to horizontal offset of last character of z
end repeat
--set the bounds to the lower left
set geometric bounds to {c - h, f, c - os, w + os}
end tell
end tell
end tell
end tell
Copy link to clipboard
Copied
Again. Thank you!
Copy link to clipboard
Copied
Rob,
Back to this again. I was trying to figure out how to get the font size to go to 8 point, but everything I do keeps it at the 12 point default. Can you help? Also, I would like to remove anything in the name after the PANTONE 1111 C in the swatch names. For example: Pantone 293 C would show up in the box as Pantone 293
Here is my script I have been using for a while with your help:
tell application id "com.adobe.indesign"
tell active document
set zero point to {0, 0}
delete unused swatches
set allSwatches to every swatch
try
set noprint to make color with properties {model:spot, space:CMYK, color value:{100, 0, 0, 0}, name:"noprint"}
on error
set noprint to every color whose name is "noprint"
end try
try
wb to make color with properties {model:spot, space:CMYK, color value:{0, 0, 0, 100}, name:"wb"}
on error
set wb to every color whose name is "wb"
end try
try
set infoLayer to make layer with properties {name:"Job Info - Non-Print", printable:true, layer color:blue}
on error
set infoLayer to every layer whose name is "Job Info - Non-Print"
end try
set ul to return & "Ink Color(s):" & return
set ds to {"None", "Registration", "Paper", "noprint", "wb", "die", "white"}
delete every page item of item 1 of infoLayer
repeat with x in allSwatches
if name of x is not in ds then
set ul to ul & name of x & return
end if
end repeat
tell page 1
set os to 0.25
set {a, b, c, d} to bounds
--makes the text frame with an initial bounds set to the the page dimensions with the list as the contents
set slugText to make new text frame with properties {geometric bounds:{a, os, c, d}, stroke color:"noprint", stroke weight:1, item layer:"Job Info - Non-Print", contents:ul}
tell slugText
set overprint stroke of slugText to true
--fits the text frame to the contents
fit given frame to content
--set the properties of the text
set properties of text 1 to {fill color:"noprint", overprint fill:true, first line indent:os * 1.5, applied font:"Helvetica LT Std", font style:"Condensed"}
--get the frame’s adjusted bounds
set {e, f, g, h} to geometric bounds
--the frame’s height
set h to (g - e) + os
--get the longest line
set ho to 0
repeat with z in lines
if horizontal offset of last character of z is greater than ho then
set w to horizontal offset of last character of z
end if
set ho to horizontal offset of last character of z
end repeat
--set the bounds to the lower left
set geometric bounds to {c - h, f, c - os, w + os + 0.75}
end tell
end tell
end tell
end tell
Copy link to clipboard
Copied
You set the point size in the text properties, so:
set properties of text 1 to {fill color:"noprint", overprint fill:true, first line indent:os * 1.5, applied font:"Helvetica LT Std", font style:"Condensed", point size:8}
Copy link to clipboard
Copied
Thank you. I swear I thought I tried that, but it wasnt working.
Any idea on how to remove the last 2 characters from the swatch name?
I saw you had something similar that would add the doc name to a swatch name, so was hoping you had an idea.
Copy link to clipboard
Copied
You would have to test the swatch names, so your swatch loop would be something like this:
repeat with x in allSwatches
set sn to name of x
if word 1 of sn is "PANTONE" and last character of sn is "C" then
set sn to text 1 thru -2 of sn
end if
if sn is not in ds then
set ul to ul & sn & return
end if
end repeat
Copy link to clipboard
Copied
This works great if the only naming convention is C. I also need it to recognize the last 2 characters as UP or CP...
How would I word it to be the last or last 2 characters in sn?
I would need it to recognize multiple pms name possibilities.
Copy link to clipboard
Copied
You would have to set up else if statements for the different endings:
repeat with x in allSwatches
set sn to name of x
if word 1 of sn is "PANTONE" and last character of sn is "C" then
set sn to text 1 thru -2 of sn
else if word 1 of sn is "PANTONE" and text -2 thru -1 of sn is "UP" then
set sn to text 1 thru -3 of sn
else if word 1 of sn is "PANTONE" and text -2 thru -1 of sn is "CP" then
set sn to text 1 thru -3 of sn
end if
if sn is not in ds then
set ul to ul & sn & return
end if
end repeat
The Pantone’s with different endings have different color values and color modes, so in a case like this there are two different colors used, but they are listed as the same name:
Copy link to clipboard
Copied
Perfect! Thank you.
Copy link to clipboard
Copied
I mean, it still doesnt completely do what I want, but I might be able to mess with it and try and figure it out.