Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How do I return the page width and height as a text variable?

New Here ,
Mar 13, 2015 Mar 13, 2015

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

TOPICS
Scripting
2.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Mar 14, 2015 Mar 14, 2015

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];

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 18, 2015 Mar 18, 2015

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 25, 2015 Mar 25, 2015

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 25, 2015 Mar 25, 2015
LATEST

There is no property geometricBounds for Page objects.

Just: bounds

See the DOM documentation:

Adobe InDesign CS6 (8.0) Object Model JS: Page

Uwe

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines