Quantcast
Channel: Adobe Community : Popular Discussions - InDesign Scripting
Viewing all 15932 articles
Browse latest View live

Where can I get a list of error codes for InDesign server

$
0
0

I am using InDesign server to process a bunch of jobs and couldn't find a list of error codes generated by InDesign Server. I am specifically looking for error codes generated in cases where InDesign client seem to have erred. To give an analogy, Apache HTTP server generates 4xx class of status code whenever client seems to have erred. Is there a similar error code list for InDesign server.

 

Eg: I wrote a job to convert .indd files to idml and purposely gave in a corrupt .indd file to convert. I got the following response code.

Error Code: 29441

Error Message: Cannot open the file "corrupt_file.indd". Adobe InDesign Server may not support the file format, a plug-in that supports the file format may be missing, or the file may be open in another application.

 

I couldn't find any reference to error code 29441 in Adobe's documentation. Any leads or references?

 

Thanks,

Chinmay


While Loop with Array.pop() Gotcha

$
0
0

Just a bit of a heads up:

 

A number of us have been using a while(obj=array.pop()){} construct for a while. (I believe Marc was the one to introduce this construct to this forum.)

 

While this is considerably more efficient than a standard for loop when you don't need the array when the loop ois done, there's a not-so-obvious gotcha:

 

0 in javascript is evaluated to false, so : while(0) is equivalent to while(false).

 

If you have an loop like this:

 

ar = [1,0,8,6];
while(a=ar.pop()){    // do your stuff    }

6 and 8 will resolve true, but 0 will not. The loop will exit when it hits 0, and neither 0 nor 1 will be processed.

 

This loop is no good either:

 

ar = [1,0,8,6];
while(a=ar.pop() != null){    //do your stuff    }

because "a" will evaluate to either true or false instead of the value of the array because statements are processed backwards (i.e. a = (ar.pop != null)).

 

Instead you need (note the extra parenthesis):

 

ar = [1,0,8,6];
while((a=ar.pop()) != null){    //do your stuff    }

 

HTH,

Harbs

How can I get a total page count of a PDF before placing every page in the PDF?

$
0
0
Before the [long] spiel, I'm using javascript in InDesign CS3.

I'd like to create a script that places a multiPage PDF in any number of different impositions. (saddle stitch, 4up signatures, 16up signatures etc.)

I've easily created a script that iterates through a PDF and places it into a new document as (4,1|2,3), (8,5|6,7) etc, which works for printing in duplex, folding each page in half, and gluing the resulting spines to make a simple thick book (for PDFs with more than, say, 64 pages).

However, the next step is to re-write the script to create a saddle stitch document (16,1|2,15), (14,3|4,13) ... (10,7|8,9). For this I need to know how many pages there are in the PDF before I start placing the PDF pages, and then making the new document [int((PDFpages+3)/4)] pages long.

Is there a simple way to get the count of PDFpages without going through a loop and placing the next page from the PDF until the placed page number equals the first page number?

This way seems wasteful:

var totPDFPages = 1;
app.pdfPlacePreferences.pageNumber = totPDFPages;
myPDFPage = sheetFront.place(File(srcPDF), [0,0])[0];
var pdfFirstPage = myPDFPage.pdfAttributes.pageNumber;
while (doneCounting == false) {
totPDFPages += 1;app.pdfPlacePreferences.pageNumber = totPDFPages;
myPDFPage = sheetFront.place(File(srcPDF), [0,0])[0];
if (myPDFPage.pdfAttributes.pageNumber == pdfFirstPage) {
totPDFPages -=1;
doneCounting = true;
alert("PDF has " + totPDFPages + " pages!");exit();
};
myPDFPage.remove();
};

NB. Javascript above *hasn't* been run, but should look similar once debugged.

The only thing I've though of to relieve the sheer duplication of placing the PDF twice (once for the count, and once for the imposition), is to create an array of impoPages[counter]=myPDFPage, and then shuffle the pages referenced by the array to the correct sheet and position.

It'd be much easier to be able to assign pageCount = File(srcPDF).pageCount !!!

Thanks for any help/tips or even a simple "What are you smoking, man!?"

Cheers,
Jezz

Compare Italic between docs

$
0
0

Hello everyone!

 

I have 2 documents:

Original.indd

Typeset.indd

 

I need to compare if that Typeset.indd has the same italics as Original.indd

Is important to know, not always the same words have italics. The same word can in a paragraph have italic and in the same paragraph not have it. Like you can see in this paragraph, with the word human:

 

All human beings are born free and equal in dignity and rights. Human endowed with reason and conscience and should act towards one another in a spirit of brotherhood, human has the right to life, liberty and security of person.

 

Is posible do this with a script?

 

 

Here are my files ready to Download

 

Any help will be appreciate. Thanks so much!

script replace/adjust/change circles with text path

$
0
0

Hi everybody,

After spending a lot of time finding for nothing, then I decided to ask for help and I hope someone has experience about the issue that I am going to tell you:

I am working on hundreds pages that contain the same below circle. My point is that I need to resize the circle A to circle B with the details below (also the text running from inside to outside).

 

I tried alot of Find/change but it didnt work.

 

 

Script Place Equation

$
0
0

I need a javascript that places all the equation in appropriate places. The script needs to search << Eqn 001.eps >> etc ... and replace the appropriate image there. Does anyone have a script like this?

making the first line in each paragraph bold

$
0
0

hello all

I have been reading this forum but i cant really seem to find the answer i need.

Here is my problem, we are planning to automate the flowing of text in our organisation, this is what i have to do

-read story entries from a database

-flow the text in to a text box of particular width eg 4.5cm

-each paragraph will be sepearted by 2 new lines

- select the first line of each paragraph then make it bold.

 

from the above list i can do everything except the select first line of paragraph and make it bold. I have been looking for text selection as far as i can see there is a function called textframe.select?

Can anybody help me out with this please?

Determine of a PNG image contains transparent pixels

$
0
0

Hi,

 

I'm exporting lots of PageItems to images using pageItem.export() method. I want the exported image to be a PNG if it contains transparent pixels, otherwise it should be a JPG.

 

So is there anyway to determine whether an exported PNG contains transparent pixels or not?


Sort algorithm: how can I sort two arrays according to one

$
0
0

I have two parallel arrays, similar to this:

 

var array1 = [4, 3, 1, 5, 2];

var array2 = ["four", "three", "one", "five", "two"];

 

I want to sort the first array, and have the second array follow the same sort as the first. Any advice for a good algorithm would be appreciated.

 

Rick Quatro

Multiple graphic frames: resize, fit content proportionally, center content

$
0
0

Hello scripting wizards! I'm hoping one of you can help me with this simple task. How I wish actions were an option! I've read the posts saying how simple apple scripting is. I've read the tutorial from start to finish and done the exercises. I've copied snippets from multiple sources and the only thing I've been able to do is fit content ... but not proportionally.

 

I'm using INDD CC. I have a dozen tabloid size pages with a hundred placed illustrator images on each. Here's what I need to do to every one of graphic frames:

1. make all the graphic frames the same size: 10mm x 10mm

2. fit content to frame proportionally

3. center content in frame

 

Can anyone help? Thanks!

Bitwise operators | and & precedence

$
0
0

I still can't believe this is possible. After few days (and nights) of debugging, I found that JSX doesn't confirms with JS specifications about '&' and  '|' operators precedence. 

In ESTK "1 | 1 & 0" results in 0. It should be the same as "1 | (1 & 0)", which is 1.

The issue I had was with an external minified library crypto-js and the debugging was real pain.

As I could't find this fact documented, I'm still wondering is that by design or it's Adobe's implementation bug?

Apply "Fit content to frame" to all TextFrame - Javascript

$
0
0

Hi,

 

I would like to use javascript to "Fit content to frame" to ALL TextFrame".

Any one can HELP!

 

Thx!

script for running multiple find/change queries

$
0
0

Working on a large ID book document (*.indb), I have saved several dozens of Find/Change Queries (named "col01", "col02" etc.) that I run on "All documents". For a particular reason I have to run these queries several times a day.

 

So I was wondering whether there is, or whether anybody out there would write, a script that runs these queries one after the other. Given the size of the book, it might be necessary to provide for the script to pause after each query is run (before it goes on with the next), but I am just guessing.

 

Any help is much appreciated!

While Loop with Array.pop() Gotcha

$
0
0

Just a bit of a heads up:

 

A number of us have been using a while(obj=array.pop()){} construct for a while. (I believe Marc was the one to introduce this construct to this forum.)

 

While this is considerably more efficient than a standard for loop when you don't need the array when the loop ois done, there's a not-so-obvious gotcha:

 

0 in javascript is evaluated to false, so : while(0) is equivalent to while(false).

 

If you have an loop like this:

 

ar = [1,0,8,6];
while(a=ar.pop()){    // do your stuff    }

6 and 8 will resolve true, but 0 will not. The loop will exit when it hits 0, and neither 0 nor 1 will be processed.

 

This loop is no good either:

 

ar = [1,0,8,6];
while(a=ar.pop() != null){    //do your stuff    }

because "a" will evaluate to either true or false instead of the value of the array because statements are processed backwards (i.e. a = (ar.pop != null)).

 

Instead you need (note the extra parenthesis):

 

ar = [1,0,8,6];
while((a=ar.pop()) != null){    //do your stuff    }

 

HTH,

Harbs

Call the Finder print window from within Indesign

$
0
0

Hi,

 

I have a few Applescripts to automate all of my print jobs.

 

Since we us a new pinter in the office, the machine uses a authentication.

That authentication is just a number provided in a submenu of the Finders Print window.

When printing manually, in the Indesign print window, we have to click the "printer" window first, click ok and then print, just to activate the authentication.

However, when I print from Indesign using a script, that print screen is ignored, so, the authentication code is also ignored.

Is there a way to call that Finder print window (and close it again) prior to the Indesign print command?

 

I hope my explanation is clear to understand :-)

Any help or suggestions are welcome.

 

Thanks!

Schermafbeelding 2018-05-07 om 13.22.03.png

 

Here's one example of one of my scripts (all credits go to MacGrunt for this)

on returnNumbersInString(inputString)  set s to quoted form of inputString  do shell script "sed s/[a-zA-Z\\']//g <<< " & s  set dx to the result  set numlist to {}  repeat with i from 1 to count of words in dx  set this_item to word i of dx  try  set this_item to this_item as number  set the end of numlist to this_item  end try  end repeat  return numlist
end returnNumbersInString


tell application id "com.adobe.InDesign"
  tell document preferences of active document  set myBleedText to document bleed top offset as string  end tell
end tell


set myBleed to returnNumbersInString(myBleedText)


tell application id "com.adobe.InDesign"
  tell active document  set theLinks to every link  repeat with aLink in theLinks  if status of aLink is link out of date then  -- update aLink  display dialog "Er zijn gewijzigde beelden aanwezig in het document, ben je zeker dat je wil verder gaan?"  else  if status of aLink is link missing then -- other options are normal/link out of date/link missing/link embedded  --missing link handling  display dialog "Er zijn ontbrekende beelden aanwezig in het document, ben je zeker dat je wil verder gaan?"  end if  end if  end repeat  set mgPgFace to facing pages of document preferences as string  set mgPgOrnt to page orientation of document preferences as string  set mgDocHght to page height of document preferences  set mgDocWdth to page width of document preferences  set mgDocHght to mgDocHght as integer  set mgDocWdth to mgDocWdth as integer  set the page range of print preferences to all pages  set mgPgHght to mgDocHght + myBleed + myBleed + 10  set mgPgWdth to mgDocWdth + myBleed + myBleed + 10  if mgPgFace is "true" then --print document as spreads  if mgPgHght is greater than 185 or mgPgWdth is greater than 130 then --use one of the A4 presets  if mgPgHght is greater than 277 or mgPgWdth is greater than 200 then --use A3 fit preset  set mgPrintPreset to "A3 comp liggend spread fit"  else --use A3 100% preset  set mgPrintPreset to "A3 comp liggend spread"  end if  else --use A4 horizontal preset  set mgPrintPreset to "A4 comp liggend spread"  end if  else --print document as single pages  if mgPgOrnt is "portrait" then --use one of the vertical presets  if mgPgHght is greater than 277 or mgPgWdth is greater than 200 then --use one of the A3 presets  if mgPgHght is greater than 400 or mgPgWdth is greater than 277 then --use A3 fit preset  set mgPrintPreset to "A3 comp staand spread fit"  else --use A3 100% preset  set mgPrintPreset to "A3 comp staand spread"  end if  else --use A4 vertical preset  set mgPrintPreset to "A4 comp staand spread"  end if  else --use one of the horizontal presets  if mgPgHght is greater than 200 or mgPgWdth is greater than 277 then --use one of the A3 presets  if mgPgHght is greater than 277 or mgPgWdth is greater than 400 then --use A3 fit preset  set mgPrintPreset to "A3 comp liggend spread fit"  else --use A3 100% preset  set mgPrintPreset to "A3 comp liggend spread"  end if  else --use A4 horizontal preset  set mgPrintPreset to "A4 comp liggend spread"  end if  end if  end if  print using (mgPrintPreset as string) without print dialog  if modified is true then save  display notification "Uw document wordt geprint" with title mgPrintPreset  end tell
end tell


print using (mgPrintPreset as string) without print dialog


if modified is true then save


display notification "Uw document wordt geprint" with title mgPrintPreset

end tell

end tell

Find and Replace Font - Redefine styles when changing all

$
0
0

Hi,

 

     I need to enable the checkbox "Redefine Style When Changing All" in Find Font dialog.  How can I enable this check box when replacing fonts??

 

 

Screen shot 2017-09-19 at 1.34.49 PM.png

 

 

- Sudha K

Dynamically populate InDesign file and publish

$
0
0

Greetings,

 

I have a database full of text and I would like to publish the data into a nicely designed InDesign file. I can easily dump the data into XML, JSON, or raw Text but is it possible to dynamically populate an InDesign file with this data then publish straight to PDF? Are there any examples of dyanmic data being published from an external source (like XML, JSON, etc.)?

Why does duplicating an element unshift the copy into the parent collection instead of pushing?

$
0
0

I am working on an essentially very simple script that is supposed to do the following:

 

  • Loop over all Rectangles in a document
  • If certain criteria are met, make a copy of the current rectangle (on a different layer) and do some stuff with it

 

I can loop over the app.activeDocument.rectangles collection with no problem, but as soon as I duplicate an individual Rectangle object, the loop break. It seems that duplicating an element unshifts the copy onto the beginning of the array of objects represented by the Rectangles collection, rather than pushing it onto the end.

 

So if I have three Rectangle objects in the document (let’s make them red, green and blue, just to tell them apart), I’d initially get a collection like this:

 

  • Rectangles[0]: redBox
  • Rectangles[1]: greenBox
  • Rectangles[2]: blueBox

 

I loop over the collection and copy the current object on each iteration like so:

 

var els = app.activeDocuments.rectangles;
var targetLayer = app.activeDocument.layers.itemByName("Target Layer");

for (i = 0, j = els.length; i < j; i++) {     var orgEl = els[i];     var newEl = orgEl.duplicate(targetLayer);     $.writeln(i + ": " + orgEl.id + " / " + newEl.id);     // do more stuff with the duplicated element here
}

 

Doing this, I would (naïvely) expect the collection to end up looking like this:

 

  • Rectangles[0]: redBox
  • Rectangles[1]: greenBox
  • Rectangles[2]: blueBox
  • Rectangles[3]: redBox Copy
  • Rectangles[4]: greenBox Copy
  • Rectangles[5]: blueBox Copy

 

– but instead this is what happens:

 

  • Rectangles[0]: redBox Copy
  • Rectangles[1]: redBox Copy
  • Rectangles[2]: redBox Copy
  • Rectangles[3]: redBox
  • Rectangles[4]: greenBox
  • Rectangles[5]: blueBox

 

In other words, when I call orgEl.duplicate() in the first iteration (i = 0), the duplicated element is unshifted into the collection at position 0, and the current element’s index is moved up one, becoming 1. On the next iteration (i = 1), naturally, I get the same element again, since its position has moved since the start of the loop.

 

Now, it is of course possible to overcome the obstacle that this presents for looping over collections, by doing this for example:

 

var els = app.activeDocuments.rectangles;
var ids = els.everyItem().id;
var targetLayer = app.activeDocument.layers.itemByName("Target Layer");


for (i = 0, j = els.length; i < j; i++) {     var orgEl = ids[i];     var newEl = orgEl.duplicate(targetLayer);     $.writeln(i + ": " + orgEl.id + " / " + newEl.id);     // do more stuff with the duplicated element here
}

 

But that’s rather unintuitive and cumbersome. I can think of several good reasons why duplicating an element onto the end of a collection would be usual and make sense, but I cannot think of a single good reason why adding it on to the beginning. All the effects I can think of are negative: the weirdness of modifying the index position of the current element, the rather significant performance hit that comes with unshifting compared to pushing, and just… general common sense.

 

So why is it that duplicate() apparently unshifts rather than pushing? Is there some logical reasoning behind this seemingly counterintuitive decision?

Apply Paragraph Styles Depending on Text Values

$
0
0

Hello everyone!

 

I want apply my custom Paragraph Styles to some text, this text have a similar Styles but not the same.

Is possible create many conditionals and apply my Custom Paragraphs Styles depending on Text Values?

 

For example: in my file Indesign.indd I want find the texts with the next values and apply my Custom Paragraph Style called Text Number locate in my folder NEW STYLES.

           fontStyle == "Roman",            pointSize <= 10.5,            spaceAfter <=1,            spaceBefore <= 3.292,            leftIndent <= 7.408,            rightIndent <= 0,            firstLineIndent <= -7.408,            hyphenation: false,            justification == Justification.LEFT_ALIGN || justification == Justification.LEFT

 

Please this script is very important for me, I appreciate any help.

Thanks so much!

Replace a letter using GREP without interfering in the GREP syntax

$
0
0

Hello!

 

Before the letter D, I try to insert a Column Break (in GREP is the character ^M) in my Index. But I can't because in GREP ^D means other thing and is not working the script.

Is important be sure don't damage other letters D

How can I add a column break before my single letter D ?

 

replaceText ("^D\r","^MD\r") 

function replaceText (input, output)  
{       app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;       app.findTextPreferences.findWhat = input;       app.changeTextPreferences.changeTo = output;       app.activeDocument.changeText();       app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;   
} 

 

My actual Index:

Screen Shot 2018-05-11 at 16.22.59.png

 

The result I expect:

Screen Shot 2018-05-11 at 16.23.27.png

 

 

Thanks so much in advance!

Viewing all 15932 articles
Browse latest View live