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

XML attribute change

$
0
0

I need to replace the xml attribute value "M05_LEMO9433_06_SE_CH05" to M05_LEMO5401_06_SE_CH05

 

 

In document having more than thousand entries

 

 

I have used the below code but it is not working

 

 

function AddReturns(){

    this.name = "AddReturns";

    this.xpath = "//p//span//a";

    this.apply = function(myElement, myRuleProcessor){

 

 

        with(myElement)

  {

  try{

                   

              //      if (myElement.xmlAttributes.item("href").value.match ("LEMO9433 "))

                        {

                           

                            var fig = myElement.xmlAttributes.itemByName("href").value;

                            var    figv =  fig.replace ("9433", "O5401")

                            myElement.xmlAttributes.itemByName("href").value=figv;

 

 

                            }

                   

                   

  //myElement.xmlAttributes.item("id").name = "olinkend";

  }catch(e){}

 

        }

        return true;

    }

}


Removing a table (VBA)

$
0
0

Hi, All.

 

How do I remove a table?

 

MySpread.TextFrames(I1).Tables(I2).Remove - doesn't work.

 

 

Thanks in advance.

Why are my tif files corrupting in indesign?

$
0
0

Hi I'm using indesign cs5 and my tif files are corrupting after they are placed into the file. Has anyone else had a similar problem? Is it a Yosemite v cs5 issue?

Memory Leak - targetengine?!

$
0
0

Hi folks,

 

I was analyzing some strange behavior of JavaScript concerning memory consumption, garbage collection. Following some questions, observations:

 

1. Inner Functions/Objects/Function Pointers:


 

function Hashtable() {

this.valueList = new Array();

var test = function() { return 1; }

this.putValue = function(name, value) {

this.valueList[name] = value;

}

}

 

for (var i = 0; i < 100000; i++) {

var hash = new Hashtable();

hash.putValue("Key" + i, "Value" + i);

delete hash;

hash = null;

}

 

Oberservation: Running the script with the inner function test, the memory will rise per loop, despite the use of delete and null per loop. Because of the memory consumption the execution time will rise exponential. Without the inner function, the memory won't rise and the script is much faster.

 

Question: What is so special on an inner function for the JavaScript engine? What kind of engine are you using, does it has a JIT compiler? Why can't I kill the object references with delete/setting null?

 

 

2. Usage of targetengine directive:

 

//Startup Scripts/script1.jsx

#targetengine "my_special_target"

function PersistentObject() {

     this.getXYZ = function() {...}

}

...

MyPersistendObject = new PersistentObject();

...


//Scripts/script2.jsx

#targetengine "my_special_target"

var newObject = new Object();

MyPersistendObject.getXYZ();

 

Oberservation: Using this code from within a Startup Script, I can create peristend objects, I can use from a second script. The second script needs to "connect" to the same targetengine to call something like MyPersistendObject.getXYZ(). That's very usefull for caching etc. But all my code within the second script seems to be peristent as well. If I run the second script, all objects will be created twice and the references of the first run will reside too. This means the memory consumption will rise linear with the objects of second script per run. The execution time will rise exponential because of expensive memory allocation.

 

Question: Does targetengine means no run of garbage collection at all? How can I override reference instead of creating new ones. Can I influence the garbage collection at all (with $.gc())? Is their a difference between the garbage collection of InDesign CS4 vs. InDesign Server  CS4?

 

Thanks for any information.

 

Tino

Memory leak while exporting indd to pdf file

$
0
0

Hi,

 

I found memory leak while converting indd file to pdf.

I export a 2.21 MB indd file and it will leak about 200kb per time.

I have reset some 'big' variables null to release and even called $.gc() but it doesn't work at all.

What's the problem.

 

Code is below:

var result = "No documents are open................";

// var argsNames=app.scriptArgs.getValue("Name").split(";")

argsNames = arguments;

var fileName = argsNames[0];

var argPreset;

var storeLocation;

if (argsNames && argsNames[1]) {

    argPreset = argsNames[1];

}

if (argsNames && argsNames[2]) {

    storeLocation = argsNames[2];

}

Log("Params:" + fileName + ";" + argPreset + ";" + storeLocation)

//OpenOptions.DEFAULT_VALUE

//OpenOptions.OPEN_ORIGINAL

//OpenOptions.OPEN_COPY

var myDocument = app.open(new File(fileName),OpenOptions.OPEN_COPY);

//Fill in a valid file path on your system.

var myFolder = new Folder(storeLocation);

var result = "saved to folder:  " + myFolder.fullName;

if (!myFolder.exists && !myFolder.create()) {

    result = "Not saved.  Unable to create the folder:  " + myFile.parent.fullName;

} else {

    //myExport2SepratedPages(myDocument, myFolder.fullName, argPreset);

    myExportAllPages(myDocument, myFolder.fullName, argPreset);

}

//myDocument.close();

myDocument = null;

//var endMark=app.performanceMetric(PerformanceMetricOptions.currentMemoryMark);

//app.dumpBetweenMemoryMarks(startMark,endMark);

result+=($.summary());

$.gc();

 

//export to a single pdf file

function myExportAllPages(myDocument, myFolderName, presetFile) {

    var start = new Date();

    var myBaseName = myDocument.name;

    myPageName = myDocument.pages.item(0).name;

    app.pdfExportPreferences.pageRange = PageRange.ALL_PAGES;

    app.importFile(ExportPresetFormat.DOCUMENT_PRESETS_FORMAT, presetFile);

    //Generate a file path from the folder name, the base document name, and the page name.

    //Replace the colons in the page name (e.g., "Sec1:1") wtih underscores.

    var myRegExp = new RegExp(":", "gi");

    myPageName = myPageName.replace(myRegExp, "_");

  //test

  var sufix=Math.random()*100000;

 

    myFilePath = myFolderName + "/" + myBaseName + "_" + myPageName +sufix+ ".pdf";

    myFile = new File(myFilePath);

    myDocument.exportFile(ExportFormat.pdfType, myFile);

  myDocument.close(SaveOptions.NO);

    myDocument = null;//delete document

    var end = new Date();

 

    Log("Start:" + start + ";End:" + end)

}

 

function GetScriptPath() {

    // This function returns the path to the active script, even when running ESTK

    try {

        return app.activeScript.parent.fsName;

    } catch (e) {

        return File(e.filePath.parent.fsName);

    }

}

 

 

function Log(message) {

    var today = new Date();

    var logFile = new File(GetScriptPath() + "/myLog.txt");

    if (!logFile.exists) {

        // make new log file

        logFile.open("w");

        logFile.write(String(today) + "\nThe following messages were logged:\n");

        logFile.close();

    }

    logFile.open("e");

    logFile.seek(0, 2);

    logFile.write("\n" + message);

    logFile.close();

     logFile=null;

}

Find nested characters and apply the Cstyle

$
0
0

I

want to find the nested applied characters and apply the Cstyle, but my code capture all those text in a document. Can you please guide to me,

 

nestedreport();

function nestedreport(){

var myDoc = app.activeDocument;

var myDocPath = myDoc.filePath;

var myDocName = myDoc.name;

 

 

try{

app.findGrepPreferences = app.changeTextPreferences = null;

app.findGrepPreferences.findWhat = "^.+";

myFind=myDoc.findGrep(false);

 

var ntexts = new Array;

for(i=myFind.length-1;i>=0;i--)

{

    if(myFind[i].contents.nestedStyles==null)

    {

        ntexts.push(myFind[i].contents)

        ntexts.appliedCharacterStyle="Nested";

        }

    }

}

catch(e){}

 

}

 

 

Screen shot 2015-07-21 at 2.26.33 PM.png

change second page size in 3-page spread

$
0
0

Hi,

 

I'm wondering, how can I change second page size in 3-page spread with ExtendScript?

(I'm trying to generate cover with spine)

"Object invalid" error for layer visible

$
0
0

Hi All,

 

I am getting the "Object invalid" error message for below code. please check and suggest me, where is error occurred in my code.

 

var myDoc =  app.activeDocument;

 

var myLayer = myDoc.layers;

 

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

  { 

      if(myLayer[i].name == "WEBPDF" && myLayer[i].visible == true)

        {  

           

            try

            {

                    myDoc.revert();

                    myLayer[i].visible = false;

                    myDoc.save();

                }

            catch(e){

                    alert(e);

                }

 

            }

      }


does InDesign support Georgian script?

$
0
0

I have tried a number of ways to input mkhedruli alphabet but InDesign doesn't seem to accept it. I have the required fonts installed. Any ideas?

How set name for new document?

$
0
0

I run to create a new InDesign document:

 

app.documents.add();

 

The new document is given a name "Untitled-1". How specify name of the document without saving?

InDesign Table - Collapse empty Row

$
0
0

My apologies if this is not posted in the proper category...


Ok, here's my issue...


I have a table with 5 rows.  Sometimes, not all of the rows in the table will contain data.  Is it possible for InDesign to automatically collapse a row if there is no data present in the cells in that row?


Thanks!

IDCC2015 (MacOSX 10.9.5) Undefined is not an object when referencing dataMergeProperties.selectDataSource

$
0
0

Hello everybody.

 

I've been working on a script that works on an open InDesign file with data merge fields. When run, the script prompts the folder for a directory of text files, then a directory to put the resulting PDFs. It looks like this:

 

#target indesign
main();

var myDoc = app.activeDocument;//the indesign file that is currently open 
function main() {     var f = Folder.selectDialog("Select the text files");    var finished = Folder.selectDialog('select folder for finished PDFs').fsName + '/'; //selects a folder to put the finished files    if (f == null) return;    var files = f.getFiles();    var imgs = new Array();    var file, ext;    for (var n = 0; n < files.length; n++) {        file = decodeURI(files[n].name);        ext = file.substring(file.lastIndexOf(".")+1,file.length);        if ( ext == "txt" || ext == "csv" || ext == "TXT" || ext == "CSV") {                  imgs.push( file );        }    }    for (var n = 0; n < imgs.length; n++) {     var mergeTo = f.absoluteURI + '/' + imgs[n];       var pdfTo = finished + imgs[n] + '.pdf'    myDoc.dataMergeProperties.selectDataSource(mergeTo);    myDoc.dataMergeProperties.exportFile(finished, "[High Quality Print]", );           }     }

 

As I step through the script in debug in ESTK, everything looks fine until line 22 when I keep getting "undefined is not an object". But when I look at the data browser, everything looks like it should be where it is:

 

Screen Shot 2015-07-22 at 9.02.02 pm.png

My thoughts are that it has something to do with the filename referencing used by selectDataSource. But I have tried dozens of permutations of the filenaming using fsName, absoluteURI, and I really am stuck... and have been for some time. I've tried not to bother the forum, and I am sure that my coding should be correct, but clearly it isn't. Any pointers to solving this would be appreciated.

 

Colin

Image catalog modification - page size same as image size, 1 image on page, double sided indd...

$
0
0

hi

I need little help. Image catalog is script which I use every day but need some modification.

1. I want that indd doc which script create is double sided

2. Every page in indd is SAME size AS image which is placed on it

3. Want to set default image location so when script ask where images is to point always in same location, not on desktop.

 

this is what i have now, 1x1 sheme, one image per page, default location desktop, single sided

 

//ImageCatalog.jsx

//An InDesign CS6 JavaScript

/* 

@@@BUILDINFO@@@ "ImageCatalog.jsx" 3.0.0 15 December 2009

*/

//Creates an image catalog from the graphic files in a selected folder.

//Each file can be labeled with the file name, and the labels are placed on

//a separate layer and formatted using a paragraph style ("label") you can

//modify to change the appearance of the labels.

//

//For more information on InDesign scripting, go to http://www.adobe.com/products/indesign/scripting/index.html

//Or visit the InDesign Scripting User to User forum at http://www.adobeforums.com .

//

//The myExtensions array contains the extensions of the graphic file types you want

//to include in the catalog. You can remove extensions from or add extensions to this list.

//myExtensions is a global. Mac OS users should also look at the file types in the myFileFilter function.

main();

function main(){

  var myFilteredFiles;

  //Make certain that user interaction (display of dialogs, etc.) is turned on.

  app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;

  myExtensions = [".jpg", ".jpeg", ".eps", ".ps", ".pdf", ".tif", ".tiff", ".gif", ".psd", ".ai"]

  //Display the folder browser.

  var myFolder = Folder.selectDialog("Select the folder containing the images", "");

  //Get the path to the folder containing the files you want to place.

  if(myFolder != null){

  if(File.fs == "Macintosh"){

  myFilteredFiles = myMacOSFileFilter(myFolder);

  }

  else{

  myFilteredFiles = myWinOSFileFilter(myFolder);

  }

  if(myFilteredFiles.length != 0){

  myDisplayDialog(myFilteredFiles, myFolder);

  alert("Done!");

  }

  }

}

//Windows version of the file filter.

function myWinOSFileFilter(myFolder){

  var myFiles = new Array;

  var myFilteredFiles = new Array;

  for(myExtensionCounter = 0; myExtensionCounter < myExtensions.length; myExtensionCounter++){

  myExtension = myExtensions[myExtensionCounter];

        myFiles = myFolder.getFiles("*"+ myExtension);

  if(myFiles.length != 0){

  for(var myFileCounter = 0; myFileCounter < myFiles.length; myFileCounter++){

  myFilteredFiles.push(myFiles[myFileCounter]);

  }

  }

  }

  return myFilteredFiles;

}

function myMacOSFileFilter(myFolder){

  var myFilteredFiles = myFolder.getFiles(myFileFilter);

  return myFilteredFiles;

}

//Mac OS version of file filter

//Have to provide a separate version because not all Mac OS users use file extensions

//and/or file extensions are sometimes hidden by the Finder.

function myFileFilter(myFile){

  var myFileType = myFile.type;

  switch (myFileType){

  case "JPEG":

  case "EPSF":

  case "PICT":

  case "TIFF":

  case "8BPS":

  case "GIFf":

  case "PDF ":

  return true;

  break;

  default:

  for(var myCounter = 0; myCounter<myExtensions.length; myCounter++){

  var myExtension = myExtensions[myCounter];

  if(myFile.name.indexOf(myExtension)>-1){

  return true;

  break;

  }

  }

  }

  return false;

}

function myDisplayDialog(myFiles, myFolder){

  var myLabelWidth = 112;

  var myStyleNames = myGetParagraphStyleNames(app);

  var myLayerNames = ["Layer 1", "Labels"];

  var myDialog = app.dialogs.add({name:"Image Catalog"});

  with(myDialog.dialogColumns.add()){

  with(dialogRows.add()){

  staticTexts.add({staticLabel:"Information:"});

  }

  with(borderPanels.add()){

  with(dialogColumns.add()){

  with(dialogRows.add()){

  staticTexts.add({staticLabel:"Source Folder:", minWidth:myLabelWidth});

  staticTexts.add({staticLabel:myFolder.path + "/" + myFolder.name});

  }

  with(dialogRows.add()){

  staticTexts.add({staticLabel:"Number of Images:", minWidth:myLabelWidth});

  staticTexts.add({staticLabel:myFiles.length + ""});

  }

  }

  }

  with(dialogRows.add()){

  staticTexts.add({staticLabel:"Options:"});

  }

  with(borderPanels.add()){

  with(dialogColumns.add()){

  with(dialogRows.add()){

  staticTexts.add({staticLabel:"Number of Rows:", minWidth:myLabelWidth});

  var myNumberOfRowsField = integerEditboxes.add({editValue:1});

  }

  with(dialogRows.add()){

  staticTexts.add({staticLabel:"Number of Columns:", minWidth:myLabelWidth});

  var myNumberOfColumnsField = integerEditboxes.add({editValue:1});

  }

  with(dialogRows.add()){

  staticTexts.add({staticLabel:"Horizontal Offset:", minWidth:myLabelWidth});

  var myHorizontalOffsetField = measurementEditboxes.add({editValue:0, editUnits:MeasurementUnits.MILLIMETERS});

  }

  with(dialogRows.add()){

  staticTexts.add({staticLabel:"Vertical Offset:", minWidth:myLabelWidth});

  var myVerticalOffsetField = measurementEditboxes.add({editValue:0, editUnits:MeasurementUnits.MILLIMETERS});

  }

  with (dialogRows.add()){

  with(dialogColumns.add()){

  staticTexts.add({staticLabel:"Fitting:", minWidth:myLabelWidth});

  }

  with(dialogColumns.add()){

  var myFitProportionalCheckbox = checkboxControls.add({staticLabel:"Proportional", checkedState:false});

  var myFitCenterContentCheckbox = checkboxControls.add({staticLabel:"Center Content", checkedState:false});

  var myFitFrameToContentCheckbox = checkboxControls.add({staticLabel:"Frame to Content", checkedState:true});

  }

  }

  with(dialogRows.add()){

  var myRemoveEmptyFramesCheckbox = checkboxControls.add({staticLabel:"Remove Empty Frames:", checkedState:true});

  }

  }

  }

  with(dialogRows.add()){

  staticTexts.add({staticLabel:""});

  }

  var myLabelsGroup = enablingGroups.add({staticLabel:"Labels", checkedState:false});

  with (myLabelsGroup){

  with(dialogColumns.add()){

  //Label type

  with(dialogRows.add()){

  with(dialogColumns.add()){

  staticTexts.add({staticLabel:"Label Type:", minWidth:myLabelWidth});

  }

  with(dialogColumns.add()){

  var myLabelTypeDropdown = dropdowns.add({stringList:["File name", "File path", "XMP description", "XMP author"], selectedIndex:0});

  }

  }

  //Text frame height

  with(dialogRows.add()){

  with(dialogColumns.add()){

  staticTexts.add({staticLabel:"Label Height:", minWidth:myLabelWidth});

  }

  with(dialogColumns.add()){

  var myLabelHeightField = measurementEditboxes.add({editValue:24, editUnits:MeasurementUnits.MILLIMETERS});

  }

  }

  //Text frame offset

  with(dialogRows.add()){

  with(dialogColumns.add()){

  staticTexts.add({staticLabel:"Label Offset:", minWidth:myLabelWidth});

  }

  with(dialogColumns.add()){

  var myLabelOffsetField = measurementEditboxes.add({editValue:0, editUnits:MeasurementUnits.MILLIMETERS});

  }

  }

  //Style to apply

  with(dialogRows.add()){

  with(dialogColumns.add()){

  staticTexts.add({staticLabel:"Label Style:", minWidth:myLabelWidth});

  }

  with(dialogColumns.add()){

  var myLabelStyleDropdown = dropdowns.add({stringList:myStyleNames, selectedIndex:0});

  }

  }

  //Layer

  with(dialogRows.add()){

  with(dialogColumns.add()){

  staticTexts.add({staticLabel:"Layer:", minWidth:myLabelWidth});

  }

  with(dialogColumns.add()){

  var myLayerDropdown = dropdowns.add({stringList:myLayerNames, selectedIndex:0});

  }

  }

  }

  }

        var myResult = myDialog.show();

        if(myResult == true){

  var myNumberOfRows = myNumberOfRowsField.editValue;

  var myNumberOfColumns = myNumberOfColumnsField.editValue;

  var myRemoveEmptyFrames = myRemoveEmptyFramesCheckbox.checkedState;

  var myFitProportional = myFitProportionalCheckbox.checkedState;

  var myFitCenterContent = myFitCenterContentCheckbox.checkedState;

  var myFitFrameToContent = myFitFrameToContentCheckbox.checkedState;

  var myHorizontalOffset = myHorizontalOffsetField.editValue;

  var myVerticalOffset = myVerticalOffsetField.editValue;

  var myMakeLabels = myLabelsGroup.checkedState;

  var myLabelType = myLabelTypeDropdown.selectedIndex;

  var myLabelHeight = myLabelHeightField.editValue;

  var myLabelOffset = myLabelOffsetField.editValue;

  var myLabelStyle = myStyleNames[myLabelStyleDropdown.selectedIndex];

  var myLayerName = myLayerNames[myLayerDropdown.selectedIndex];

  myDialog.destroy();

  myMakeImageCatalog(myFiles, myNumberOfRows, myNumberOfColumns, myRemoveEmptyFrames, myFitProportional, myFitCenterContent, myFitFrameToContent, myHorizontalOffset, myVerticalOffset, myMakeLabels, myLabelType, myLabelHeight, myLabelOffset, myLabelStyle,  myLayerName);

        }

  else{

  myDialog.destroy();

  }

  }

}

function myGetParagraphStyleNames(myDocument){

  var myStyleNames = new Array;

  var myAddLabelStyle = true;

  for(var myCounter = 0; myCounter < myDocument.paragraphStyles.length; myCounter++){

  myStyleNames.push(myDocument.paragraphStyles.item(myCounter).name);

  if (myDocument.paragraphStyles.item(myCounter).name == "Labels"){

  myAddLabelStyle = false;

  }

  }

  if(myAddLabelStyle == true){

  myStyleNames.push("Labels");

  }

  return myStyleNames;

}

function myMakeImageCatalog(myFiles, myNumberOfRows, myNumberOfColumns, myRemoveEmptyFrames, myFitProportional, myFitCenterContent, myFitFrameToContent, myHorizontalOffset, myVerticalOffset, myMakeLabels, myLabelType, myLabelHeight, myLabelOffset, myLabelStyle,  myLayerName){

  var myPage, myFile, myCounter, myX1, myY1, myX2, myY2, myRectangle, myLabelStyle, myLabelLayer;

  var myParagraphStyle, myError;

  var myFramesPerPage = myNumberOfRows * myNumberOfColumns; 

  var myDocument = app.documents.add();

  myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.MILLIMETERS;

  myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.MILLIMETERS;

  var myDocumentPreferences = myDocument.documentPreferences; 

  var myNumberOfFrames = myFiles.length;

  var myNumberOfPages = Math.round(myNumberOfFrames / myFramesPerPage);

  if ((myNumberOfPages * myFramesPerPage) < myNumberOfFrames){ 

  myNumberOfPages++;

  }

  //If myMakeLabels is true, then add the label style and layer if they do not already exist.

  if(myMakeLabels == true){

  try{

  myLabelLayer = myDocument.layers.item(myLayerName);

  //if the layer does not exist, trying to get the layer name will cause an error.

  myLabelLayer.name;

  }

  catch (myError){

  myLabelLayer = myDocument.layers.add({name:myLayerName});

  }

  //If the paragraph style does not exist, create it.

  try{

  myParagraphStyle = myDocument.paragraphStyles.item(myLabelStyle);

  myParagraphStyle.name;

  }

  catch(myError){

  myDocument.paragraphStyles.add({name:myLabelStyle});

  }

  }

  myDocumentPreferences.pagesPerDocument = myNumberOfPages; 

  myDocumentPreferences.facingPages = false; 

  var myPage = myDocument.pages.item(0); 

  var myMarginPreferences = myPage.marginPreferences;

  var myLeftMargin = myMarginPreferences.left; 

  var myTopMargin = myMarginPreferences.top; 

  var myRightMargin = myMarginPreferences.right; 

  var myBottomMargin = myMarginPreferences.bottom; 

  app.marginPreferences.top = 0;

  app.marginPreferences.bottom = 0;

  app.marginPreferences.left = 0;

  app.marginPreferences.right = 0;

  var myLiveWidth = (myDocumentPreferences.pageWidth - (myLeftMargin + myRightMargin)) + myHorizontalOffset

  var myLiveHeight = myDocumentPreferences.pageHeight - (myTopMargin + myBottomMargin)

  var myColumnWidth = myLiveWidth / myNumberOfColumns

  var myFrameWidth = myColumnWidth - myHorizontalOffset

  var myRowHeight = (myLiveHeight / myNumberOfRows)

  var myFrameHeight = myRowHeight - myVerticalOffset

  var myPages = myDocument.pages;

  // Construct the frames in reverse order. Don't laugh--this will 

  // save us time later (when we place the graphics). 

  for (myCounter = myDocument.pages.length-1; myCounter >= 0; myCounter--){ 

  myPage = myPages.item(myCounter);

  for (var myRowCounter = myNumberOfRows; myRowCounter >= 1; myRowCounter--){ 

  myY1 = myTopMargin + (myRowHeight * (myRowCounter-1));

  myY2 = myY1 + myFrameHeight;

  for (var myColumnCounter = myNumberOfColumns; myColumnCounter >= 1; myColumnCounter--){ 

  myX1 = myLeftMargin + (myColumnWidth * (myColumnCounter-1));

  myX2 = myX1 + myFrameWidth;

  myRectangle = myPage.rectangles.add(myDocument.layers.item(-1), undefined, undefined, {geometricBounds:[myY1, myX1, myY2, myX2], strokeWeight:0, strokeColor:myDocument.swatches.item("None")}); 

  }

  }

  }

  // Because we constructed the frames in reverse order, rectangle 1 

  // is the first rectangle on page 1, so we can simply iterate through 

  // the rectangles, placing a file in each one in turn. myFiles = myFolder.Files; 

  for (myCounter = 0; myCounter < myNumberOfFrames; myCounter++){ 

  myFile = myFiles[myCounter]; 

  myRectangle = myDocument.rectangles.item(myCounter);

  myRectangle.place(File(myFile));

  myRectangle.label = myFile.fsName.toString();

  //Apply fitting options as specified.

  if(myFitProportional){

  myRectangle.fit(FitOptions.proportionally);

  }

  if(myFitCenterContent){

  myRectangle.fit(FitOptions.centerContent);

  }

  if(myFitFrameToContent){

  myRectangle.fit(FitOptions.frameToContent);

  }

  //Add the label, if necessary.

  if(myMakeLabels == true){

  myAddLabel(myRectangle, myLabelType, myLabelHeight, myLabelOffset, myLabelStyle, myLayerName);

  }

  }

  if (myRemoveEmptyFrames == 1){ 

  for (var myCounter = myDocument.rectangles.length-1; myCounter >= 0;myCounter--){ 

  if (myDocument.rectangles.item(myCounter).contentType == ContentType.unassigned){

  myDocument.rectangles.item(myCounter).remove();

  } 

  else{

  //As soon as you encounter a rectangle with content, exit the loop.

  break;

  }

  }

  }

}

//Function that adds the label.

function myAddLabel(myFrame, myLabelType, myLabelHeight, myLabelOffset, myLabelStyleName, myLayerName){

  var myDocument = app.documents.item(0);

  var myLabel;

  var myLabelStyle = myDocument.paragraphStyles.item(myLabelStyleName);

  var myLabelLayer = myDocument.layers.item(myLayerName);

  var myLink =myFrame.graphics.item(0).itemLink;

  //Label type defines the text that goes in the label.

  switch(myLabelType){

  //File name

  case 0:

  myLabel = myLink.name;

  break;

  //File path

  case 1:

  myLabel = myLink.filePath;

  break;

  //XMP description

  case 2:

  try{

  myLabel = myLink.linkXmp.description;

  if(myLabel.replace(/^\s*$/gi, "")==""){

  throw myError;

  }

  }

  catch(myError){

  myLabel = "No description available.";

  }

  break;

  //XMP author

  case 3:

  try{

  myLabel = myLink.linkXmp.author

  if(myLabel.replace(/^\s*$/gi, "")==""){

  throw myError;

  }

  }

  catch(myError){

  myLabel = "No author available.";

  }

  break;

  }

  var myX1 = myFrame.geometricBounds[1];

  var myY1 = myFrame.geometricBounds[2] + myLabelOffset;

  var myX2 = myFrame.geometricBounds[3];

  var myY2 = myY1 + myLabelHeight;

  var myTextFrame = myFrame.parent.textFrames.add(myLabelLayer, undefined, undefined,{geometricBounds:[myY1, myX1, myY2, myX2], contents:myLabel});

  myTextFrame.textFramePreferences.firstBaselineOffset = FirstBaseline.leadingOffset;

  myTextFrame.parentStory.texts.item(0).appliedParagraphStyle = myLabelStyle;

}

Merge different text boxes in InDesign one

$
0
0

Hi,

 

I have converted PDF2ID files, these files are showing different text boxes, if any scripting is there we can merge all text boxes in one box.

 

 

Thanks

Kishor

how to use conditional text through vbscript?

$
0
0

Hi

I want to add some conditional texts to my indesign document.

Can anyone please tell me how can i do that through vbscript or vb.net?

 

Please help.

 

Thanks


We able to generate the cross-reference link for indesign autofootnote

$
0
0

Hi All,

 

We able to generate the cross-reference link for indesign autofootnote  using javascript. Please suggest me.

 

Regards,

~Jack

Applied font style of paragraph

$
0
0

Hi,

 

     Paragraph contains more than one fontstyle.  If i use the below code, its return only one font style name. 

 

    alert( app.selection[0].fontStyle)

 

     How can i get all applied font style of paragraph??

 

 

Thanks in advance,

Sudha K

How to add a character style in active doc

$
0
0

Hi experts

 

How to create a character style in active doc.

 

how to make the script as be works.

 

Thanks

Regard

John

 

var myCharacterStyle;

var myDocument = app.activeDocument;

var myCharacterStyle = myDocument.characterStyles.add({name:"c"});

myCharacterStyle.strikeThru = true;

myCharacterStyle.strokeColor = "Black";

    myCharacterStyle.add()

Export table as html with border

$
0
0

Hi,

 

   When i am exporting table into html file  using indesign javascript, its exporting table as html without border using the below code.

 

   How can i export the table with border using indesign javascript without css option??

 

htmlPath = File(app.activeDocument.fullName.fsName.replace(".indd",".html"));  

app.activeDocument.htmlExportPreferences.viewDocumentAfterExport = true;

app.activeDocument.htmlExportPreferences.cssExportOption = StyleSheetExportOption.NONE;

app.activeDocument.exportFile(ExportFormat.HTML, htmlPath, false);

 

Screen shot 2015-07-24 at 1.45.19 PM.png

 

 

Screen shot 2015-07-24 at 1.57.35 PM.png

 

Thanks in advance,

Sudha K

move table within a textframe?

$
0
0

Hii

Can anyone please tell me how can I move a table within a textframe?

Is it possible to do so using vb.net?

Please please help

 

Thanks

Viewing all 8771 articles
Browse latest View live


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