Copy link to clipboard
Copied
Hi
I'm trying to create a media box for use in job to return information in the slug area. I have a script that will return the username of the computer as a text variable but I would also like to return the height and width in mm as a text variable too. Does anyone know how to this please?
Thanks
Copy link to clipboard
Copied
Assuming you have already created the two custom text type variables and you have named them PageWidth and PageHeight respectively. Also, assuming your document has a uniform page size, otherwise using text variables for this makes no sence:
var doc=app.activeDocument;
var pageW=doc.textVariables.item('PageWidth');
var pageH=doc.textVariables.item('PageHeight');
var gb=doc.pages[0].geometricBounds;
pageW.contents=gb[3]-gb[1];
pageH.contents=gb[2]-gb[0];
Copy link to clipboard
Copied
Hi Vamitul
Thank you for your response. I very new to scripting so I hope you'll bare with me.
How do I apply your code to indesign please? At the moment I have a script that returns the computer user name(an online script i found called 'addCustomVariables_103.jsx') that's going to be one of the variables I use in my media box. This lives in the startup scripts folder but i'm guessing I can't just add your code to it as yours will require an open document to return any values. How would I apply your code so it works in inDesign? Ideally i could do with this automatically adding the text variables at startup as I'll be installing this on several machines.
Thanks once again for your assistance.
Copy link to clipboard
Copied
To use that code in indd
1. Write code in Adobe ExtendScript save it
2. Copy the jsx file
3. Open indd document. Go to Window -> Utilities -> Script. Inside that go to Application -> Samples -> JavaScript and right click on JavaScript folder -> Select Reveal in Explorer.
4. Paste the jsx file in that location
One the file have been placed you'll be able to view it inside JavaScript folder. To execute script right click on script and select Run Script.
Copy link to clipboard
Copied
There is no property geometricBounds for Page objects.
Just: bounds
See the DOM documentation:
Adobe InDesign CS6 (8.0) Object Model JS: Page
Uwe
Find more inspiration, events, and resources on the new Adobe Community
Explore Now