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

Need to select ALL tables

$
0
0

Hi,

 

I import Word documents in InDesign CC, wich contains several tables.

I need to select ALL tables and then change the size of the text inside the cells and I need to change the table strokes inside and the table-border.

I know how to install a script in InDesign – though I have not yet tried to work with a script ...

... hope my first time will be succesfull :-))))

 

Hope that somebody can help me.

 

 

Regards,

Pia (graphic designer)


How to remove custom color in a Script UI control?

$
0
0

Dear forum,

 

I’m writing a script for batch renaming links in InDesign.

1.jpg

If the user types in the text edit field the new name which coincides with the original link’s name (the 1st static text in the group), the script gives a warning and paints it red.

2.jpg

3.jpg

When the user corrects the issue by making the new name different, the script paints it black.

15-11-2015 20-30-37.jpg

 

Here’s where I got so far:

g.et.onChange = function() {    if (this.parent.children[0].text.replace(/\.[^\.]+$/, '') == this.text) {        alert("\"" + this.text + "\" - the new name is the same as the old one! The file won't be renamed.", "Error", true);        this.graphics.foregroundColor = this.graphics.newPen(this.graphics.PenType.SOLID_COLOR, [1, 0, 0], 1);    }    else {        if (this.graphics.foregroundColor != undefined) {            $.writeln("Names are different: change the name from red to black.");                                   this.graphics.foregroundColor = this.graphics.newPen(this.graphics.PenType.SOLID_COLOR, [0, 0, 0], 1);        }    }
}

 

"g.et" is the edit text in a group.

I wonder is there a way to reset the text’s color back to defaults instead of repainting it?

Currently it checks if foregroundColor of graphics is not undefined – that is painted with “newPen” – and if it is true, paints it with black. But I suspect it’s a clumsy workaround and there should be a proper way to do this.

   

Regards,

Kasyan

Graphic Line Anchors...

$
0
0

The script below from GitHub (Graphic Lines · fabiantheblind/auto-typo-adbe-id Wiki · GitHub) creates the path shown below...

 

The anchor location for each point matches the position of the point before it.

 

I want to create a path made only of straight lines and have been trying, unsuccessfully, to either remove the anchors or to make the anchor positions match the position of the point they're drawn from.

 

Does anybody have any suggestions?

 

Thanks very much for any help.

 

gline.png

var data = {

   "pw":100,

   "ph":100,

   "anchors":[

  [  0,50],

  [ 10,60],

  [ 20,40],

  [ 30,60],

  [ 40,40],

  [ 50,60],

  [ 60,40],

  [ 70,60],

  [ 80,40],

  [ 90,60],

  [100,50]

  ]

  };

 

   // we need a doc

   // use pw and ph from data

   var doc = app.documents.add({

  documentPreferences:{

  pageHeight:data.ph,

  pageWidth:data.pw

  }

  });

 

   // the page is already there

   var page = doc.pages.item(0);

 

   // create a graphicLine

 

   var gl = page.graphicLines.add();

 

   // loop thru the data.anchors

   for(var i in data.anchors){

   var point = gl.paths[0].pathPoints[i];

   /**

  * a graphicLine always has 2 pathpoints

  * so we need to add points only from the third

  * anchor from the data object

  */

 

   if(i <2){

  point.anchor = data.anchors[i];

  }else{

  point = gl.paths[0].pathPoints.add();

  point.anchor =  data.anchors[i];

  }

 

   if((i != data.anchors.length-1)&& i!=0)

 

  point.rightDirection = data.anchors[i-1];

  point.leftDirection = data.anchors[i];

  }

Thanks very much for any help.

gline.png

Can you make a CEP / HTML5 user interface refresh or redraw while a script is running?

$
0
0

Hi,

 

I was hoping that the interface in CEP / HTML5 forms for InDesign would be updating and refreshing while a jsx script was running.

 

I do get events from my jsx code. These events update a progress bar in the js/HTML part of my extension, but it is not until everything is completely done that the graphical user interface (HTML) is redrawn and the progress is actually shown.

Neither is the InDesign document (the contents) redrawn while my script is running.

 

I've got a loop in the jsx script that of course is very "intensive", but since events are supported and the html part ought to be fairly disconnected (not so?) from the code, I thought that it should be able to refresh better than the old ScriptUI based interface.

 

The "Enable redraw" setting has probably no effect on this kind of code (anyway I see no difference when testing it, so that's not the way).

 

What can be done, are there any explanations to this?

I thought the switch to a HTML interface would make it easier to implement cancel buttons and stuff like that, that was very hard to do with the "old" ScriptUI.

 

Thanks,

Andreas

Speeding Grep queries

$
0
0

Hi all,

 

Looking at boosting my script performance and notice that the only part really performance and time consuming are some Grep FC queries. So I am wondering what could be the best practices to speed up things.

 

Actually I am executing the queries onto the document but would fractionning queries for every single stories be a better practice ?

 

Thanks in advance for your hints.

 

Loic

How to draw cross line?

$
0
0

  <- Cross Line

 

Hi.

 

I want to draw cross line using JavaScript.

 

 

 

 

I can draw this line.

app.activeDocument.graphicLines.add(undefined, undefined, undefined,{geometricBounds:[100,100,300,300]})

 

 

 

but I can't draw this line.

I tried to "geometricBounds:[300,100,100,300] and [100,300,100,300]" but it was not drawn.

 

 

 

I tried to apply the transform option but line has moved.

 

It is moving again, but I want to simply left and right reversal .

 

Any ideas?

 

Thanks.

trim marks as a spot color

$
0
0

I need to have my page trim marks export out as a spot color in my .pdfs... This way they will show on my .pdf printed proofs, but can be turned off when I need to send file to platesetter.

Is there a script for assigning a spot color to my Trim and bleed guidelines, instead of CMYK vegetable colors???

How to display the frame at the export?

$
0
0

<- InDeisgn

                           Text frame                                   Rectangle Frame                                  Rectangle

 

 

<- Export the image

 

 

Hi.

 

As above, the frame of the text frame, the frame of the rectangle frame is not displayed when it export as an image.

 

I want to display frame to image exported using JavaScript

 

Any Ideas?

 

Thanks.


How to copy all object?

$
0
0

Hi.

 

I want to copy and paste all of the object.

 

app.activeDocument.rectangles.everyItem().select();

app.cut();

 

I can copy(or cut) and paste only so one type of object.

 

How to copy all of the objects?

 

Thanks.

Indesign table gets collapsed

$
0
0

Hi!!!,

 

My project is converting the hyperlink column of a indesign table into its equivalent QR Codes. The script works fine if i update and change the values of fields in Xml. If i try to add a new column in Xml and update it using our own plugins, it doesn't works well instead of adding column the script adds rows so the whole values gets collapsed. Some one help me out in this.

 

My Basic Questions are

  1) Is it possible to add QR code inside a Table cell programatically [ i did that,but still not sure about the restrictions].

  2) Why the added column in xml adding as a row in my indesign table ?[may be coz of QRCode in nearby cell?]

 

 

Thanks & Regards

R.D.RajKumar

Changing Font Colors

$
0
0

Im in the process of writing a script that converts picks to BW and relinks them. I seem to be having problem getting the correct syntax to find all the text boxes and change them to black (except for any font with a fill color of paper.

I've been experimenting just to get one of them to change, once I get one the rest should be easy

tellapplication "Adobe InDesign CS6"

  telldocument 1

  --set allTextBoxes to text frames of page 1

  --repeat with textboxnum from 1 to count allTextBoxes

  selecttext frame 1

  setfill coloroftext frame 1 toswatchcolorblack

  --end repeat

  endtell

endtell

 

can anybody help

Combining Scripts

$
0
0

I am in now way a scripting guy, but I found 2 scripts that each partially do what I need. (Thanks to Kasyan)

 

Batch update links

Update path names in links

 

I'm curious if anyone knows of a script that can combine the two functions. Open, update, and change path names, save, then close.

 

I need to update all of the UNC paths (\\SERVER\Folder) to T:\

 

Thanks in advance!

including carriage return with XML table data

$
0
0

I'm inserting some data using XML into a table in an InDesign frame.
As part of the text, I'd like to put some carriage returns so that the text has a line break where I'd like it rather than have InDesign do its best guess as to how to split up the lines.

I've tried putting &#8629; and <br/>in the text, but that didn't do what I hoped it might.

 

Any suggestions?

 

Thanks!

I need a script code to mass remove prices.

Applescript: How do I attach a script to an event??

$
0
0

I have an applescript that creates PDF and uploads it to a specific destination. (see below)

 

I want to invoke this script every time the user "saves" the doc.

 

I am a novice when it comes InDesign applescripting...I don't know if its possible to attach a script to the "save" function??

 

I am guessing I need to incorporate an event listener?? again i am guessing. perhaps there is a better way? attach the script to key combo Command-s??

 

the objective is to give the user the option to send a PDF every time they save a document.

 

Here is the script thus far:

 

......................

 

set _ExportPDF to (display dialog "Send Proof?" with iconcautionbuttons {"Cancel", "PDF"} default button 2)

tell application "Adobe InDesign CS6"

  if button returned of _ExportPDF is "PDF" then

  set myFolder to "PDFProofs:"

  set _dest to myFolder as Unicode text

  set screenSettings to PDF export preset "[High Quality Print]"

  set page range of PDF export preferences to all pages

  set docName to name of document 1

  if docName ends with ".indd" then

  set docName to text 1 thru -6 of docName

  end if

 

  tell application "Adobe InDesign CS6"

  exportdocument 1 formatPDF typeto (_dest& docName& ".pdf") usingscreenSettings without options

  if modified of active document is true then

  tell active document to save

  closedocument 1

  end if

  (*

           tell PDF export preferences

               set view PDF to true

           end tell

           *)

  end tell

  end if

end tell

 

......................


Export/Create stories and assingments - InCopy

$
0
0

Hello everyone!

I'm looking for a script export the stories and create the Assigments.

Anyone know any better?

What got so far is:

#target indesign
//--------------------------------------------------------------------------------------------------------------
var myUserName = "Leonardo";
var asgnName = "Editoração";
var baseName = "Features_inside";
var userColor = InCopyUIColors.GOLD;
var storyRef = app.selection[0];//assumes selection is text frame
var docRef = app.documents.item(0);
docRef.save();
var docPath = docRef.filePath.absoluteURI;
var storyPath = docPath + "/Assignments/content/"
var asgnPath = docPath + "/Assignments/" + asgnName + ".icma"
if (!docRef.assignments.itemByName(asgnName).isValid) {    var asgnRef = docRef.assignments.add({name:asgnName,    userName:myUserName, frameColor:userColor, exportOption:AssignmentExportOptions.ASSIGNED_SPREADS,    filePath:asgnPath});
} else {    var asgnRef = docRef.assignments.itemByName(asgnName);
}
var storyName = baseName + ".icml";
var icmlPath = new File(storyPath + storyName);
storyRef.exportFile (ExportFormat.INCOPY_MARKUP, icmlPath);
var unasgnRef = docRef.assignments.lastItem();
var unasgnName = unasgnRef.name;
if (unasgnName != asgnName) {     unasgnRef.assignedStories.lastItem().move(LocationOptions.AT_END, asgnRef);
}
asgnRef.update();
docRef.save();

var myDoc = app.activeDocument;
var myInDesignVersion = Number(String(app.version).split(".")[0]);
// Check contitions
if (app.documents.length == 0) ErrorExit(localize({en: "Nenhum documento está abertas. Por favor, abra um documento e tente novamente."}), true);
if (!myDoc.saved) ErrorExit(localize({en: "Este arquivo nunca foi salvo. Salve-o e executar o script novamente."}), true);
if (myInDesignVersion < 5) ErrorExit(localize({en: "This script requiers InDesign CS6 or above."}), true);


var myLayer = myDoc.activeLayer;
var myDialogSel = CreateDialog();
var myStories = [];
var myCounter = 0;


switch(myDialogSel) {
  case 1:  GetStories(myDoc.allPageItems);  break;  case 2:  GetStories(myLayer.allPageItems);  break;  case 3:  GetStoriesSelection(myDoc.selection);  break;
}


var myPath = myDoc.filePath +"/Users/leonardo.mari/Desktop/InCopy";
var myFolder = new Folder(myPath);
if (!myFolder.exists) myFolder.create();


if (myStories.length > 0) {  ProcessStories(myStories);
}
else {  ErrorExit(localize({en: "No stories to be exported have been found."}), true);
}


Report();


// ------------------ FUNCTIONS ------------------
function ProcessStories(myStories) {
  var myProgressWin = new Window ( "window", localize({en: "Export Stories to InCopy"}));  var myProgressBar = myProgressWin.add ("progressbar", [12, 12, 350, 24], 0, myStories.length);  var myProgressTxt = myProgressWin.add("statictext", undefined, localize({en: "Starting"}));  myProgressTxt.bounds = [0, 0, 340, 20];  myProgressTxt.alignment = "left";  myProgressWin.show();  for (var j = 0; j < myStories.length; j++) {  myProgressBar.value = myCounter + 1;  myProgressTxt.text = String(localize({en: "Exporting story "}) + (myCounter + 1) + localize({en: " of "}) + myStories.length);  var myStory = myStories[j];  var myFileName = GetFileNameOnly(myDoc.name) + "-" + myStory.id + ".icml";  var myFilePath = myFolder.fsName + "/" + myFileName;  var myFile = new File(myFilePath);  try { // in case a srory is in anchored text frame  myStory.exportFile(ExportFormat.incopyMarkup, myFile);  }  catch (myError) {  $.writeln(myError);  }  myCounter++;  }  myProgressWin.close();
}
// ------------------------------------------------
function GetStories(myItems) {  for (var i = 0; i < myItems.length; i++) {  if (myItems[i].constructor.name == "TextFrame") {  if (myItems[i].parentStory.itemLink == null) {  if (!IsObjInArray(myItems[i].parentStory, myStories)) {  myStories.push(myItems[i].parentStory);  }  }  }  }
}
// ------------------------------------------------
function GetStoriesSelection(mySelItems) {  for (var s = 0; s < mySelItems.length; s++) {  if (mySelItems[s].constructor.name == "TextFrame") {  if (mySelItems[s].parentStory.itemLink == null) {  if (!IsObjInArray(mySelItems[s].parentStory, myStories)) {  myStories.push(mySelItems[s].parentStory);  }  }  }  else if (mySelItems[s].constructor.name == "Group") {  var myItems = mySelItems[s].allPageItems;  GetStories(myItems);  }  }
}
// ------------------------------------------------
function IsObjInArray(myObj, myArray) {  for (x in myArray) {  if (myObj.id == myArray[x].id) {  return true;  }  }  return false;
}
// ------------------------------------------------
function GetFileNameOnly(myFileName) {  var myString = "";  var myResult = myFileName.lastIndexOf(".");  if (myResult == -1) {  myString = myFileName;  }  else {  myString = myFileName.substr(0, myResult);  }  return myString;
}
// ------------------------------------------------
function ErrorExit(myError, myIcon) {  alert(myError, localize({en: "Export Stories to InCopy"}), myIcon);  exit();
}
// ------------------------------------------------
function CreateDialog() {  var myDialog = new Window("dialog", localize({en: "Export Stories to InCopy"}));  var myPanel = myDialog.add("panel", undefined, localize({en: "Export:"}));  myPanel.alignChildren = "left";  var myRadioBtn1 = myPanel.add("radiobutton", undefined, localize({en: "all in the active document"}));  var myRadioBtn2 = myPanel.add("radiobutton", undefined, localize({en: "all on the active layer: \""}) + myLayer.name + "\"");  var myRadioBtn3 = myPanel.add("radiobutton", undefined, localize({en: "only selection"}));  if (app.extractLabel("Kas_ExportInCopy_RadioBtnSelected_1.2") != "") {  eval("myRadioBtn" + app.extractLabel("Kas_ExportInCopy_RadioBtnSelected_1.2") + ".value= true");  }  else {  myRadioBtn1.value = true;  }  if (app.selection.length == 0) {  myRadioBtn3.enabled = false;  if (myRadioBtn3.value) myRadioBtn1.value = true;  }  var myButtonsGrp = myDialog.add("group");  var myOkBtn = myButtonsGrp.add("button", undefined, localize({en: "Ok"}), {name:"ok"});  var myCancelBtn = myButtonsGrp.add("button", undefined, localize({en: "Cancel"}), {name:"cancel"});  var myDialogResult = myDialog.show();  if (myDialogResult == 1) {  var myRadSelected;  if (myRadioBtn1.value) {  myRadSelected = 1;  }  else if(myRadioBtn2.value) {  myRadSelected = 2;  }  else if(myRadioBtn3.value) {  myRadSelected = 3;  }  app.insertLabel("Kas_ExportInCopy_RadioBtnSelected_1.2", myRadSelected + "");  return myRadSelected;  }  else {  exit();  }
}
// ------------------------------------------------
function Report() {  if (myCounter == 0) {  alert(localize({en: "Nothing has been exported."}), localize({en: "Export Stories to InCopy"}));  return;  }  else if (myCounter == 1) {  var myEnding = localize({en: " story"});  }  else if (myCounter >= 2 && myCounter <= 4) {  var myEnding = localize({en: " stories"});  }  else if (myCounter >= 5) {  var myEnding = localize({en: " stories"});  }  alert(localize({en: "Exported "}) + myCounter + myEnding + ".", localize({en: "Export Stories to InCopy"}));
}
// ------------------------------------------------
function GetDate() {  var myDate = new Date();  if ((myDate.getYear() - 100) < 10) {  var myYear = "0" + new String((myDate.getYear() - 100));  } else {  var myYear = new String ((myDate.getYear() - 100));  }  var myDateString = (myDate.getMonth() + 1) + "/" + myDate.getDate() + "/" + myYear + " " + myDate.getHours() + ":" + myDate.getMinutes() + ":" + myDate.getSeconds();  return myDateString;
}

 

I thank anyone who can help.

loading text into mouse cursor ?

$
0
0

Hi,

I am banging my head against wall after hours of research. What I want to achieve is to load text data into cursor so one can just click and have the text placed within InDesign. I know placeGun and I can imagine placing some text files. But if you ever do some text selection outside of iNDesign and place it into the latter, the text is perfectly placed.

Any direction to advise ?

Thanks in advance,

Loic

Can I disable redraw for file placement

$
0
0

I have a script that places some files into a place in InDesign, however it's slow because it's updating every file. I have this set

app.scriptPreferences.enableRedraw = false;

But it still updates after every placement?

Sort color swatches in InDesign

$
0
0

Some of the larger publications that I work on accumulate a gazillion color swatches, and I would like to be able to sort them. In the past I've done this manually, by CMYK value. But this is time-consuming and often results in visually convoluted arrangements. The greens are not all together, there are pastels up in the reds and yellows, etc. I would like to do this with a script, to save time and make it more perceptually pleasing and useful.

 

Any help or advice would be much appreciated. Or if you're a scripting angel, maybe you'd like to write it for me. I've written scripts before, but I'm not sure the best way to iterate through the swatches, or how to sort them into folders or group them.

 

The basic sorting method I want is to group the swatches in folders like so (each bullet point would be a separate folder in the Swatches palette — or maybe just grouped together in a flat list — could be an option in the script ... and the formula that follows each bullet points describes the criteria for the colors in that group and how they would be sub-sorted):

 

  • Magentas: If M >127 and CYK <64, sort by density
  • Reds: If MY >127 and CK <64, and M>=Y, sort by density
  • Oranges: If MY >127 and CK <64, and Y>M, sort by density
  • Yellows: If Y >127 and CMK <64, sort by density
  • Warm Greens: If CY >127 and MK <64, and Y>=C, sort by density
  • Cool Greens: If CY >127 and MK <64, and C>Y, sort by density
  • Cyans: If C >127 and MYK <64, sort by density
  • Blues: If CM >127 and YK <64, and C>=M, sort by density
  • Purples: If CM >127 and YK <64, and M>C, sort by density
  • Darks: All values are >85, sort by dominant CMY, then by density
  • Pastels: All values are <15, sort by dominant CMY, then by density
  • Grays: Any where the CMY values are +/- 5 from their average (which also includes CMY=0), sort by dominant CMY value then by density.
  • Everything else: Sort by dominant CMY then by density


(In the above section, "If MY >127" means, "If M and Y are both individually less than 127", etc.)


For gray calculation: Average = (C+M+Y)/3


For density sorting: Density = L from (L * a * b), or other formula to calculate lightness/darkness value such as: Density = (C * 0.49) + (M * 0.6) + (Y * 0.07) + (K * 0.91)


For RGB swatches, convert RGB colors and process as CMYK?


Drop all spot colors in their own folder (or at top of list).


Drop all gradients in their own folder (or at end of list).

wie kann ich das Script PlaceMultipagePDF anpassen?

$
0
0

z.B. mehrere PDFs auf einer Seite, Koordinaten..?

Viewing all 8771 articles
Browse latest View live


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