Quantcast
Channel: Adobe Community : All Content - InDesign Scripting
Viewing all 8771 articles
Browse latest View live

How to get the response of a vbscript ran from extended js?

$
0
0

Hi All,

 

I  want to get the result from a vbscript, how to get that in my jsx? This is what I'm doing-

 

 

vbscript (this will return me something, i've added just a sample string)

 

Wscript.Echo "Like this?"

 

 

jsx

 

 var a = File("C:\\Users\\Sahil\\AppData\\Roaming\\CreativeWorx\\1.vbs");
 var b=a.execute();

 

Now, variable b returns me true/false; and the output i.e."Like this?"  is alerted! So my question is-

 

1. How to get the output in a variable?

2. How to avoid the alert

 

So, I simply wish to get the output from my vbscript and then perform certain functions accordingly, alos, I dont want  this to be alerted!

 

 

Any help will be highly appreciated!


[JS][CS5] PlaceXML fails. What Am I Doing Wrong?

$
0
0

Hi everyone,

 

I have an XML file which I can place manually but I'm trying to automate the process with a script but I cannot work out why the script is failing. It falls over with an Error 30477.

 

The document has several different types of master spreads and the XML is organised into appropriate sections. Based on the section in the XML file, I need to create a page, apply the right master page and place the XML.

 

The script creates the page, applies the master but fails when placing the xmlElement. I've tried several different approaches and searched everywhere for an answer but cannot work out why.

 

Can anyone tell me what I'm doing wrong?

    

 

/*  Places XML section on appropriate pages */

 

alert("Starting Process");

var myDocument = app.activeDocument;

 

var currentPage;

var masterSpread;

 

var xmlBook = myDocument.xmlElements[0].xmlElements[0];

 

if ( xmlBook.markupTag.name.toString() == 'book' ) {

    // In the right place

    for ( var lp = 0; lp < xmlBook.xmlElements.length; lp++) {

        var xmlElement = xmlBook.xmlElements[lp]; // Structural element in the book

        switch ( xmlElement.markupTag.name.toString() ) {

            case "standard":

               

                var currentPage = myDocument.pages.add(LocationOptions.AT_END);

                var masterSpread = myDocument.masterSpreads.itemByName('S-Standard');

                currentPage.appliedMaster = masterSpread;   

 

                var targetFrame = myDocument.pages.lastItem().textFrames[0];

   

                /* Throws:   Error 30477 Invalid value for parameter 'using' */               

                xmlElement.placeXML(targetFrame);

               

                break;

        }

       

    }

 

} else {

    alert(xmlBook.markupTag.name);   

    throw { name: 'FatalError', message: 'XML Structure wrong' };

 

}

 

 

Sample XML

 

<?xml version="1.0" encoding="UTF-8"?>

<document domain="http://6d6rpg.com/wiki/" id="member:tregenza:pdfprinttestbook" revision="0" lastmod="1398592877">

<book colour="#f05177" bookTitle="PDF Print Test Book" >

<standard><header4 >Test Wiki Page</header4>

<p>Test of wiki content for the &lt;page&gt; syntax.</p>

<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus facilisis suscipit laoreet. Nunc vel viverra est. Morbi massa arcu, suscipit eget massa a, faucibus pellentesque mi. Cras tristique, nibh cursus faucibus vestibulum, est velit gravida odio, vitae pretium erat libero non sem. Cras commodo gravida rhoncus. Nam nec rutrum leo. Fusce gravida rutrum ipsum, ut ultricies libero pulvinar in. Suspendisse at rhoncus mi. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla porta quam vel turpis iaculis, ut hendrerit nibh semper. Nunc ornare egestas dui eu dictum. Mauris lorem dolor, dignissim nec velit et, semper venenatis libero. Pellentesque gravida mauris magna, at pretium tellus tempor sed.</p>

<p>Quisque venenatis vehicula ultricies. Nulla sit amet ornare orci, sed molestie mi. Proin quis tempus ante. Etiam auctor aliquam pretium. Nam pellentesque justo sem, a lacinia tortor euismod sed. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Suspendisse ut neque ipsum. Nam convallis at metus non ullamcorper. Morbi a orci quam. Quisque rhoncus neque a auctor porttitor. Fusce auctor cursus tellus, luctus aliquet turpis vehicula ut. Donec at sagittis erat. Vivamus sit amet elit vel dolor sollicitudin molestie sed sed turpis.</p>

<p>Integer dictum, mauris non aliquet scelerisque, nunc odio mattis sapien, sit amet porttitor mi ante quis ligula. Fusce in feugiat arcu, at cursus magna. Aliquam dignissim lorem in risus adipiscing, vitae iaculis sem ullamcorper. Cras eu libero sem. Nulla cursus mattis luctus. Sed porttitor, arcu consectetur malesuada ultrices, sapien nunc tincidunt justo, vel rutrum diam quam eget mi. Praesent pretium ac risus sed tempor. Cras condimentum, mi id facilisis pretium, turpis ipsum mollis nisi, ac posuere nunc dui vitae risus. Sed adipiscing purus a diam accumsan, a rhoncus tortor pellentesque. Morbi et dui quis mauris ornare commodo et quis eros. </p>

<header4 >Test Wiki Page</header4>

<p>Test of wiki content for the &lt;page&gt; syntax.</p>

<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus facilisis suscipit laoreet. Nunc vel viverra est. Morbi massa arcu, suscipit eget massa a, faucibus pellentesque mi. Cras tristique, nibh cursus faucibus vestibulum, est velit gravida odio, vitae pretium erat libero non sem. Cras commodo gravida rhoncus. Nam nec rutrum leo. Fusce gravida rutrum ipsum, ut ultricies libero pulvinar in. Suspendisse at rhoncus mi. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla porta quam vel turpis iaculis, ut hendrerit nibh semper. Nunc ornare egestas dui eu dictum. Mauris lorem dolor, dignissim nec velit et, semper venenatis libero. Pellentesque gravida mauris magna, at pretium tellus tempor sed.</p>

<p>Quisque venenatis vehicula ultricies. Nulla sit amet ornare orci, sed molestie mi. Proin quis tempus ante. Etiam auctor aliquam pretium. Nam pellentesque justo sem, a lacinia tortor euismod sed. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Suspendisse ut neque ipsum. Nam convallis at metus non ullamcorper. Morbi a orci quam. Quisque rhoncus neque a auctor porttitor. Fusce auctor cursus tellus, luctus aliquet turpis vehicula ut. Donec at sagittis erat. Vivamus sit amet elit vel dolor sollicitudin molestie sed sed turpis.</p>

<p>Integer dictum, mauris non aliquet scelerisque, nunc odio mattis sapien, sit amet porttitor mi ante quis ligula. Fusce in feugiat arcu, at cursus magna. Aliquam dignissim lorem in risus adipiscing, vitae iaculis sem ullamcorper. Cras eu libero sem. Nulla cursus mattis luctus. Sed porttitor, arcu consectetur malesuada ultrices, sapien nunc tincidunt justo, vel rutrum diam quam eget mi. Praesent pretium ac risus sed tempor. Cras condimentum, mi id facilisis pretium, turpis ipsum mollis nisi, ac posuere nunc dui vitae risus. Sed adipiscing purus a diam accumsan, a rhoncus tortor pellentesque. Morbi et dui quis mauris ornare commodo et quis eros. </p>

</standard>

<appendix>

<header4 >Autofire</header4>

<p>Quisque venenatis vehicula ultricies. Nulla sit amet ornare orci, sed molestie mi. Proin quis tempus ante. Etiam auctor aliquam pretium. Nam pellentesque justo sem, a lacinia tortor euismod sed. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Suspendisse ut neque ipsum. Nam convallis at metus non ullamcorper. Morbi a orci quam. Quisque rhoncus neque a auctor porttitor. Fusce auctor cursus tellus, luctus aliquet turpis vehicula ut. Donec at sagittis erat. Vivamus sit amet elit vel dolor sollicitudin molestie sed sed turpis.</p>

</appendix>

</book></document>

Modal dialog question

$
0
0

I'm working with files that have their assets managed via a DAM that wants the user to log in whenever a file is opened. This log-in window doesn't respect the "script preferences/never interact" direction and pops up with every new file opened in a batch process, requiring the user to dismiss each one so it can go on process each file.

 

I can see how to check by script whether there's a modal dialog active by checking the modal state, but if that's showing as "true" is there a way via script to target the dialog and dismiss it?

 

Failing this, I'll have to enforce that users either log into this system or disable the plug-ins, but I was hoping to get something that would require no action on their part other than running the script.

 

InDesign CS5.5, Mac OX 10.6.8, working on an AppleScript, but I'd also be happy to hear any JavaScript ideas!

 

Thanks,

 

Mary

Getting the correct page number

$
0
0

Hi, Im stuck with this project...

 

I have this xml tag

<page id="p4" type="cyan">some content</page>

 

so, what I want to do is, use this attributes to apply a B-Cyan, B-Magenta or B-Yellow master spread to

(well to whatever page number there is on the tag) in this case page 4 (and 5 implicitly)

 

 

im stuck here

 

 

if( !myRoot.xmlAttributes.itemByName("xmlns:xml").isValid )

myRoot.xmlAttributes.add( "xmlns:xml", "http://www.w3.org/XML/1998/namespace" );

if( !myRoot.xmlAttributes.itemByName("xmlns:aid").isValid )

myRoot.xmlAttributes.add( "xmlns:aid", "http://ns.adobe.com/Adobe InDesign/4.0/" );

if( !myRoot.xmlAttributes.itemByName("xmlns:aid5").isValid )

myRoot.xmlAttributes.add( "xmlns:aid", "http://ns.adobe.com/Adobe InDesign/5.0/" );

//

//**Types of pages

var myPageNode= myRoot.evaluateXPathExpression("//page");

 

 

for (var x = 0; x < myPageNode.length; x++){

 

                    var pageNumber  =  myPageNode[x].xmlAttributes.itemByName("id").value.replace("p","").re place(" ","");

                    var myTypeOfPage = myPageNode[x].xmlAttributes.itemByName("type").value;

 

                    if (myTypeOfPage = "cyan"){

                         app.activeDocument.pages.itemByName().appliedMaster = app.activeDocument.masterSpreads.item("B-Cyan")

                                                }

                    if (myTypeOfPage = "magenta"){

                        app.activeDocument.pages.itemByName().appliedMaster = app.activeDocument.masterSpreads.item("B-Magenta")

                        }

                    if (myTypeOfPage = "yellow"){

                        app.activeDocument.pages.itemByName().appliedMaster = app.activeDocument.masterSpreads.item("B-Yellow")

                        }

                    };

 

 

i dont know how to pass the correct value to: pages.itemByName( my page tag id number should get here )

 

 

help!!!!!!!!!!!

resize pages based on elements

$
0
0

Hey,

need to do this:

I have multiple pages on single InDesign document, each page has one single text frame which contains a table with different heights. I'd need to resize the pages based on the size of the text frame. Since there is more than 100 pages, doing it by hand with Page Tool is a bit of frustrating task.

 

Any idea how to make a script/action out of it?

Why doesn't the #target directive work in InDesign CC scripting?

$
0
0

I have a script which works fine when run from ExtendScript Toolkit on both InDesign CS4 and InDesign CC -- but I am unable to specifically target CC using the #target directive.

 

At the top of my .jsx file, if I put:

 

#target "InDesign-6.0"

 

Then the script will open InDesign CS4 and run the script. However, if I put:

 

#target "InDesign-9.0"

 

It throws a dialog error "InDesign-9.0" is undefined! I've tried 8.0 and 9.1 just in case I had the version number wrong; nothing works.

 

Now, it is true that I can get it to work by simply adding:

 

#target "InDesign"

 

which targets the latest installed version, CC. BUT this is not a solution, just a workaround! I want to be absolutely sure I am targeting the specific version specified. Someday I may install a newer version alongside it, and then all of a sudden it will "jump" to that version when the script runs, and that's not what I want.

 

Any suggestions?

Not understanding result of rectangle moving

$
0
0

I'm building a script that will need to select some images, and move their image boxes (parent), to the left or the right.

 

I have the script loop through an array of images(PDFs) in the document, and finds the ones I need by filepath

once the image path matches the requsted path, I find (and select for visual conformation) the parent (rectangle) of the image.

This all works. where my confusion lies is when it moves.

when I move it the parent moves, but the image stays in position. When you select the parent manuallly in indesign and move it that way the rectangle and image move together.

 

Why is this not working as expected.

 

 

 

for(var i=0; i<imageArray.length; i++)

  {

      var myCurrentimage = myDoc.pageItems.itemByID(imageArray[i]).itemLink.filePath;

      if (myCurrentimage==ServiceHeader_6col )

      {

 

          var headerUsed = myDoc.pageItems.itemByID(imageArray[i]).parent

         myDoc.select(headerUsed )

         var headerBounds = headerUsed.geometricBounds;

         alert(headerBounds);

         headerBounds[1] = 100

         headerBounds[3] = headerBounds [3]+100

         headerUsed.geometricBounds= headerBounds

       }

 

   }

Loading "external library" get "I/O error" in mac

$
0
0

Hey everyone,

I just discovered the "external library" in extendscript. So I opened up the "samplelib" example in Xcode 5 and buit it. But, when I tried to run the script, I keep getting the "I/O error" at line "var sampleLib = new ExternalObject("lib:" + libPath);" . I tried to change the "SampleLib.framework" file to readable and writable for every user, but it didn't help.

 

So, guys, any idea what I've been doing wrong?

 

Thanks!!!


How to access the contents applied with 'conditional text'?

$
0
0

Hello All,

 

I'd like to access the contents applied with 'conditional text' say 'english' without switching ON using JS, please advise.

 

Thanks,

 

Praveen

add icon to last node

$
0
0

Hi All,

 

I need and javascritp to insert an anchored icon to just before of every paragraph return (\r) of last xml node in box environment in indesign file.

 

Indesign contains xml as follows:

 

box

     para

     para

          list

 

box

     para

     para

     para

 

Is anyone help me?

 

Thanks,

Swa

 

Is it possible to call Distiller and Acrobat?

$
0
0

Hey there again...

 

Following my question in http://forums.adobe.com/thread/1449735?tstart=0 , I need to use the 2 PSs I've made, convert them to PDF and concatenate both of them in a single PDF file.

 

What I need to know is:

  • do I need to go to Applescript to invoque Distiller and Acrobat?
  • Or is it possible in ExtensionScript to call Distiller and Acrobat to execute this?

 

If it is possible to do it in ExtensionScript how may it could be done?

 

 

Thanks again for the help!!

Disable reveal in explorer button

$
0
0

I want to disable "reveal in explorer" button in 'find font' wndow which comes after clicking Type->Find Font. can it be done by using scripting?

Alphabetically order text frames?

$
0
0

I have a document with multiple pages, and each page has 5 text frames.

Is it possible to alphabetically sort those text frames thoughout the document by the heading of each individuall text frame?

Tagging italics question

$
0
0

I've created two grep queries that I use to tag the italics of placed text. Then I manually apply the Basic Paragraph clear overides style. Then I run another Grep querry that takes the words and sentences that have the tags and applies an italic style that I created in the Character style pallet. Here is my Grep Querry for find and Tag italics.

 

Find What:

(.+)

 

Change to:

[i]$1[/i]

 

Find Format:

+Italic

 

Here is My Querry for appling italic character style to tagged text.

 

Find What:

(\[\i\])(.+?)(\[/\i\])

 

Change to:

$2

 

What I'm wondering is if this all could be run from a javascript including applying the Basic Paragraph clear overrides part. I'm not sure where to even begin as I'm new to scripting. Any help would be very appriciated. Thanks.

Alert Document Size

$
0
0

I use CS6

 

my Script is below:

 

var width = app.activeDocument.documentPreferences.pageWidth;

var height = app.activeDocument.documentPreferences.pageHeight;

alert("Paper Size: " + width + "mm x " + height+ "mm");

 

but I found if I use A4 size 210 x 297

it will alert 209.999999999936 x 296.9999999461

 

if I use custom size, e.g. 230x 230

it will alert right size

 

is it CS6 bug?


Find and Replace Fonts In All Book Documents?

$
0
0

Hey everyone,

 

So I have a group of indd's that I've booked, but each doc uses three fonts that I'd like to swap out for a different 3. Is there a script out there to find and replace these three fonts for all the docs in the book at once?

 

Thanks in advance!

 

-Andy

text height to frame height

$
0
0

Hi everyone,

 

Im new to forum and scripting...

 

I just want to get help from you for thebelow stuff.

 

there is a single text frame which contains the text "Learn2Gro". and the point size is 5pt.

 

I want to scale the text height to the height of the frame.

 

i tried with transform options.  but it transforms to different sizes.....

 

please see the attachment for further understanding....

textheight.png

thanks for the help....

mas....

Remove Local Formatting AS or JS

$
0
0

I'm working on a script (AS, but I can link to a JS script from it if necessary) that replaces italic, bold, bold italic, small caps, etc., with character styles. Once that's done, I'd like to go through an entire ID file and remove any other local formatting (kerning, extra space above and below, leading changes, etc.).

 

I know how to do this from the Find/Replace dialog (search for TX, replace with TX), but can't quite figure out how to script it and have it do the same for all paragraph styles in a job.

 

Thanks in advance, gurus!

Convert table/cell style to text script

$
0
0

Hi, hoping someone can help with a script that will convert only some tables in a document to text, using CC.  I have a lot of long documents with nested tables and need to convert just the "outside" table (a single cell).  Some of them have a table/cell style applied, others are manually formatted but will have a consistant border size.

I have no scripting experience and apologise if this question has been asked and answered before.  I can't seem to find quite what I am looking for.

Thanks,

M

learn jsx

$
0
0

I really want to learn jsx script, but how can I get start. What become first.

Viewing all 8771 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>