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

With CS5, some things have changed

$
0
0

This discussion is for changes to the scripting DOM which can affect legacy scripts.

 

Please use this discussion for discussing new scripting features in CS5.

 

Please keep in mind that all changes are specific to version 7 DOM. InDesign supports versioning, so you should be able to use legacy scripts in CS5 without issues. Versioning can be done in two ways:

 

1) Place the script in a folder named: "Version 6.0 Scripts" (or 5.0, 4.0, 3.0). The folder must be named exactly as specified.

2) Set the script version preferences at the start of your script. (i.e. app.scriptPreferences.version = 6), but it's highly recommended to reset the scripting version at the end of the script, and even to enclose the script in a try/catch/finally block to ensure that the script preferences are reset correctly.

 

Here's quick links to issues brought up in this thread:

  1. PageItem.parent
  2. PageItem.itemByName()
  3. PageItem.cornerOption and PageItem.cornerRadius
  4. Text values returned as Strings instead of Numbers
  5. PointType.LINE_TYPE was changed to PointType.PLAIN
  6. PasteBoardPreference.minimumSpaceAboveAndBelow was removed.

Harbs


Font size script

$
0
0

Hi, i was hoping it was possible to create a script to reduce all fonts in a given document down a point size (example: a heading at 16pt and a paragraph text at 12pt would then become 15pt and 11pt respectivly). I ask because I have a document and paragraph styles have not been used!! So is this possible and if so could anyone help with coming up with a relevant script? It also has to be able to work within tables!

 

Many Thanks

 

Rob

Underline the last word found in a particular paragraph

$
0
0

I have a problem.

When I use Grep expression to find a specific word, the whole word is searched based on the story.

But the word I'm looking for is a specific word at the end of the paragraph.

I want to underline the character style only in the last word of the whole paragraph.

I want to know how to implement with Grep expressions or scripts.

 

 

For example,

 

 

I have a dream.

I have a dream. I have a dream.

I have a dream. I have a dream. I have a dream, too.

I have a dream. I have a dream. I have a dream, too. Dream come true.

Text movement due to bookmark

$
0
0

How do I control the text movement when I add bookmark. Any one please suggest to solve the same.

export each layer of a InDesign file (with 5 pages) to its own PDF.

$
0
0

I'm not sure if this is possible...but I am looking for a way (possibly a script?) to export each layer of a InDesign file to its own PDF.

I have a 5 page indesign file and each page has 3 layers, so the exported pdf would have 15 pages. Does anyone know of a way to do this?

 

 

 

[Moved by moderator from InDesign to InDesign Scripting]

 

 

.

Indesign image count

$
0
0

Hi All,

 

Please help me I have lot of indesign files and I have check all pages images count so if you can help me a developed a java script so my work is so easy for example 2 page we have used 20 images script crated a page no and give me how many image i have used.

Convert an image file to Base64 or other string value

$
0
0

Hi,

I need toread the contentof an image file(JPEG, PNG,TIFF) andconvert that file toBase64string.

Does anyone know ifyou cando these thingson Javascript, in InDesign?

Thanks forany help

EDIT: I forgot toadd thatI knowmy imagepath onthe filesystem,itresidesinsideof my filesystem. I obtain that path thanks to InDesign...

How to get Track Changes inserted / deleted text?

$
0
0

Hi,

 

I read the Adobe InDesign CS6 JavaScript Scripting Guide and wrote a JavaScript as below:

 

var myChanges = app.documents.everyItem().stories.everyItem().changes;
var myString = '';
for (var i=0; i<myChanges.length; i++) {        var myChange = myChanges[i];        myString += myChange.userName + '\t';        myString += myChange.date + '\t';        myString += myChange.changeType + '\n';
}
alert(myString);

 

My script can get the user name, date and change type.

 

But the guide has not cover on how we can get the insert / delete modifications?

 

Many Thanks!


Subscript basic chemical formulas

$
0
0

Hi

 

I work on a biweekly agricultural magazine in which basic chemical formulas (CO2, CH4, N2O, ...) regularly appear, so naturally I want to automate the subscript part of these formulas with a GREP style in my paragraph style.

I have found a very robust GREP expression (I only use the 'Down' part) to find the numbers and change them to subscript (Credit to Vasco Elbrecht).

(?<=[(Na)|(Cl)|(H)|(C)|(O)|(S)|(N)])\d{1,3}(?=[(Na)|(Cl)|(H)|(C)|(O)|(S)|(N)|( )|(\()])

Now the problem is that in my case the formulas are used in sentences, so they can be followed immediately by a period, a comma, closing bracket and some other punctuation marks. This has not been implemented in Elbrecht's script so I tried to modify it (with my minimal GREP knowledge) to my needs, which resulted in this:

(?<=[(Na)|(Cl)|(H)|(C)|(O)|(S)|(N)])\d{1,3}(?=[(Na)|(Cl)|(H)|(C)|(O)|(S)|(N)|( )|\)])

But now when I just type some numbers (less than 4) between brackets, they will be put in subscript too, which of course is not necessary...

Is there any way this can be solved? Or should I just keep changing the numbers manually?

 

Cheers,

Laurens

 

Bonus:  tried to write a little grep script for mm, cm, m and km squared or cubed superscript (only if preceded by a number and a space), but I could not figure out how to put them all in one script, so now I have these two GREP styles:

(?<=\d m)(2|3)

(?<=\d (c|m|k)m)(2|3)

Is there any way to combine these two in one script?

Move parent frames using grep search

$
0
0

I will appreciate anyone that can point me in the right direction, my eyes are crossing from looking at scores of pages looking for solutions—probably in front of my nose.

 

Background:

We create ID pages by importing an XML file which is generated from our database. Photos and text/copy populate the page in individual frames from the fields in the database. However, empty fields in the database create frames as well. While they have no "real" content they do have some invisible tag characters.

 

My problem:

This is part of a larger script but for the moment my main concern is just some way for the script to distinguish between the "empty" frames and ones with live content (actual text characters) so these boxes can been moved to the pasteboard for possible future use.

 

If it's of any value, their constructor attribute is "TextFrame" BUT under the "Object/Content" menu, all is greyed out (no option to choose text, graphic, or unassigned, this is true regardless of whether the frames contain actual live content or not)

 

Below are two strategies I have tried:

 

1.   **********************************

//This only moves completely overset text frames (which I don't want) and empty text boxes created in Indesign manually which is not relevant. It does not move any of the XML generated "empty" frames.

 

    var myStories = app.activeDocument.stories.everyItem().getElements();

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

    var myTextFrames = myStories[i].textContainers;

    for (j = myTextFrames.length - 1; j >= 0; j--)    {

        if (myTextFrames[j].contents == ""){

            myTextFrames[j].move([-2, 0]);

        }

    }

}

 

2.   **********************************

I have used the script below with success in other scripts. However to capture text frames with no real characters I tried using the regex expression "\A\Z". This WORKS in the Indesign Find/Change utility, but when I use this expression for ".findWhat = '\A\Z';" it returns the alert "Error Number:21 Error String: undefined is not an object"

 

// Find empty text boxes and move

    app.findGrepPreferences = NothingEnum.nothing;

    app.changeGrepPreferences = NothingEnum.nothing;

    app.findChangeGrepOptions.properties = {includeFootnotes:false, includeHiddenLayers:false, includeMasterPages:true};

    app.findGrepPreferences.findWhat = '\A\Z';

 

    var noText = document.findGrep();

    var noTextFrame = noText[0].parentTextFrames[0];

   

// Move empty frame

noTextFrame.move([-2, 0]);

   

//Reset Grep parameters to null

    app.findGrepPreferences = NothingEnum.nothing;

    app.changeGrepPreferences = NothingEnum.nothing;

**********************************

Thanks in advance

Execute a VBScript inside a JavaScript

$
0
0

Hi there

How are you doing?

 

I´ve found an excellent script from IndiSnip [InDesign® Snippets] | Adobe® InDesign® Scripting Snippets

It´s a VBScript that I would like to use inside a JavaScript.

When I use it as a VBS file, everything works good, but I am not successful when I write it in JavaScript using the
app.doScript('My VBSCript line', ScriptLanguage.visualBasic);

I did it in many ways, I could not complete the script in debug mode.

Anyone could help me?

 

Link of script:

Get network adapter Name/MAC/Speed | IndiSnip [InDesign® Snippets]

 

Thanks

 

strComputer = "."

 

 

SetobjWMIService = GetObject("winmgmts:\\"& strComputer & "\root\cimv2")

SetIPConfigSet = objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")

 

SetobjWMI = GetObject("winmgmts:\\"& strComputer & "\root\WMI")

SetAdaptInfo = objWMI.InstancesOf("MSNdis_LinkSpeed WHERE Active = True",48)

 

ForEachadaptInfo in AdaptInfo

    AdaptNameLink = AdaptNameLink & adaptInfo.InstanceName & vbNewLine

    AdaptSpeed = AdaptSpeed & adaptInfo.NdisLinkSpeed & vbNewLine

Next

 

ForEachIPConfig in IPConfigSet

    IfNotIsNull(IPConfig.Description) Then

        AdaptName = AdaptName + IPConfig.Description & vbNewLine

    EndIf

    IfNotIsNull(IPConfig.MACAddress) Then

        MACadd = MACadd + IPConfig.MACAddress & vbNewLine

    EndIf

Next

 

app.scriptArgs.SetValue "myAdaptNameLink", AdaptNameLink

app.scriptArgs.SetValue "myAdaptSpeed", AdaptSpeed

app.scriptArgs.SetValue "myAdapt", AdaptName

app.scriptArgs.SetValue "myMAC", MACadd

[JS] How to get folder count?

$
0
0

Hi.

 

I want to get a number of folders for a specific directory.

 

 

 

 

var folderCount = Folder("C:/test/file/").getFiles( ? );    // Is this what values need?

alert(folderCount.length);

 

 

 

 

If this method is wrong, please tell me the other way.

 

Thanks

.indexOf is not a function :(

$
0
0

Hi there,

 

im struggeling with this simple task:

 

var myAlphas = image.clippingPath.alphaChannelPathNames;

var AlphaIndex = myAlphas.indexOf("our_default");

 

…because even this example doesnt work:

var fruits = ["Banana", "Orange", "Apple", "Mango"];

var a = fruits.indexOf("Apple");

alert(a);

 

from JavaScript Array indexOf() Method

 

All I get is
Bildschirmfoto 2017-05-18 um 15.11.15.png
and since Im more of a designer than a scripter, i cant solve that by myslef. Someone to the rescue?

Replace only the selected short list of words by the full definition description from a Longer list

$
0
0

Hello everybody

 

I've a selected short list from definitions book

 

And I want to add the full definitions description line to my selected definitions only

 

for example this is a small part from my selected text which I put them between this symbols @@@ and %%%:

 

@@@aedoeology%%%

@@@agriology%%%

@@@agrology%%%

@@@agronomics%%%

-------------------------------------------------------------------

 

and this is the big list example:

 

And I put at the end of each definition description this symbols ###

 

@@@acarology%%%

study of mites###

@@@accidence%%%

grammar book; science of inflections in grammar###

@@@aceology%%%

therapeutics###

@@@acology%%%

study of medical remedies###

@@@acoustics%%%

science of sound###

@@@adenology%%%

study of glands###

@@@aedoeology%%%

science of generative organs###

@@@aerobiology%%%

study of airborne organisms###

@@@aerodonetics%%%

science or study of gliding###

@@@aerodynamics%%%

dynamics of gases; science of movement in a flow of air or gas###

@@@aerolithology%%%

study of aerolites; meteorites###

@@@aerology%%%

study of the atmosphere###

@@@aeronautics%%%

study of navigation through air or space###

@@@aerophilately%%%

collecting of air-mail stamps###

@@@aerostatics%%%

science of air pressure; art of ballooning###

@@@agonistics%%%

art and theory of prize-fighting###

@@@agriology%%%

the comparative study of primitive peoples###

@@@agrobiology%%%

study of plant nutrition; soil yields###

@@@agrology%%%

study of agricultural soils###

@@@agronomics%%%

study of productivity of land###

------------------------------------------------------------------------------------------ --------------------

 

NOW:

 

How can I copy from the long list the full definition

 

starting from its headword and taking the full line description until the symbols ###

 

for only the selected text for my short list??????

 

Now we have:

 

First grep search:

@@@.*?%%%

 

to be replaced by:

 

second grep search:

@@@.*?%%%.*?####

                                                                  --------------------------------------------------------------

 

Any Help I will be so thankful ....

export each layer of a InDesign file (with 5 pages) to its own PDF.

$
0
0

I'm not sure if this is possible...but I am looking for a way (possibly a script?) to export each layer of a InDesign file to its own PDF.

I have a 5 page indesign file and each page has 3 layers, so the exported pdf would have 15 pages. Does anyone know of a way to do this?

 

 

 

[Moved by moderator from InDesign to InDesign Scripting]

 

 

.


running footer page range 1-10

$
0
0

I need to set as the page ranges as a running footer like ( 1- 10) in the template for each and every pages. How to do this using text variable

 

I don't want to update the current page number

 

i need to updated the first page number - last page number

Script execution delay while re-booting the InDesign CC2018

$
0
0

Hi All,

Kindly advice on the below.

 

Our process:

1. Start to run the applescript,

2. The applescript close our current InDesign application,

3. Applescript move the fonts in Application Font folder

4. Applescript open the InDesign application

5. Once application was open, the Javascript execute to Unzip the font folder (getting more delay to execute the Javascript - more than 3min)

 

Note: But the same process is working with in a minute on CC2015 and 17.

 

Important: As per use requirement, no need to place the Javascript (check point 5) in 'Startup Script'

 

Anything need to disable or updated in CC2018?

 

 

 

 

 

Thanks in advance,

Selva

Script to get the image height and width

$
0
0

I need to know the size (dimensions) of images placed in an InDesign 5.5 document.

 

I have made the following script by combining different code. It gets the metadata OK, but the witdh and height are empty. Am I using getProperty wrong?

 

// Refr
// https://forums.adobe.com/thread/288764
// https://forums.adobe.com/thread/2288546          var scriptName = "Get description from selected link",      doc;            PreCheck();        //exif:PixelXDimension   tiff:ImageWidth    //===================================== FUNCTIONS ======================================      function Main(image) {          var link = image.itemLink,          metadata = link.linkXmp,           description = metadata.description,        format = metadata.format,        author = metadata.author,        modificationDate= metadata.modificationDate,        creator = metadata.creator,        myLinkWidth = metadata.getProperty("http://ns.adobe.com/tiff/1.0/", "tiff:ImageWidth"),        myLinkLength = metadata.getProperty("http://ns.adobe.com/tiff/1.0/", "tiff:ImageLength"),         Width = metadata.getProperty("http://ns.adobe.com/exif/1.0/", "exif:PixelXDimension"),        Height = metadata.getProperty("http://ns.adobe.com/exif/1.0/", "exif:PixelYDimension");        alert("Description is: '" + description + "'\nFormat: " + format + "\nAuthor: " + author + "\nDate modified: " + modificationDate + "\nCreator: " + creator, scriptName, false);         alert("Pixel dimentions of image:\nWidth: " + myLinkWidth + Width + " pixels\nHeight: " + myLinkLength + Height +" pixels");    }      //--------------------------------------------------------------------------------------------------------------------------------------------------------      function PreCheck() {          var image;          if (app.documents.length == 0) ErrorExit("Please open a document and try again.", true);          doc = app.activeDocument;          if (doc.converted) ErrorExit("The current document has been modified by being converted from older version of InDesign. Please save the document and try again.", true);          if (!doc.saved) ErrorExit("The current document has not been saved since it was created. Please save the document and try again.", true);          if (app.selection.length == 0 || app.selection.length > 1) ErrorExit("One image should be selected.", true);                    if (app.selection[0].constructor.name == "Image") { // image selected with white arrow              image = app.selection[0];          }          else if (app.selection[0].images.length > 0) { // container selected with black arrow              image = app.selection[0].images[0];          }          else {              ErrorExit("No image in the selection.", true);          }                Main(image);      }      //--------------------------------------------------------------------------------------------------------------------------------------------------------      function ErrorExit(error, icon) {          alert(error, scriptName, icon);          exit();      }      //--------------------------------------------------------------------------------------------------------------------------------------------------------  

 

I'll explain why I'm doing this:

I'm making a magazine and the photos we get are in all different sizes and quality. In a layer called "picName" I have text frames on top of images with information from Text Variables such as name of file, PPI, actual PPI, dimensions, and scale. I make a pdf of the magazine and while my editor proof reads and edits the document I fix the photos (I cannot use InDesign at same time as she.). I use the information from the picName-layer and an Excel-sheet to determine the right size of the images, and then I edit the images in Photshop.

 

It would be a lot easier to have the calculation in the pdf itself. What I hope to achive is:

 

  1. Get the width (W) of the linked image.
  2. Get the PPI (P) of the linked image.
  3. Get the scale (S) of the image in the frame (percent).
  4. Calculate the width the image should have: W * S * 300 / P
  5. Insert the width the image should have in a text frame in the picName-layer on top of the image.

InDesign Server crashes during simple data merge

$
0
0

Hey all, wasn't sure if this belonged in InDesign Server Developers forum, or here. Sorry if in wrong place.

 

I have a simple data merge script which works perfectly fine in InDesign CC Desktop:

var source = File("/Users/toddshark/Desktop/InDesign Server/example/example.indd")

var destination = File("/Users/toddshark/Desktop/InDesign Server/example/example.pdf")

var sourceData = File("/Users/toddshark/Desktop/InDesign Server/example/example.csv")

var doc = app.open(source);

doc.dataMergeProperties.selectDataSource(sourceData);

doc.dataMergeProperties.dataMergePreferences.recordNumber = 1;

doc.dataMergeProperties.mergeRecords();

var myPDFExportPreset = app.pdfExportPresets.item(0);

app.documents.item(0).exportFile(ExportFormat.pdfType, destination, false, myPDFExportPreset);

app.documents.item(0).close(SaveOptions.no);

doc.close(SaveOptions.no);

 

I pass this same script to InDesign server, and it crashes on the .mergeRecords();.

 

The server gives back (after ~3 seconds):

./InDesignServer: line 13: 72872 Segmentation fault: 11  "$installed_name" "$@"

 

Then crashes.

 

Anyone know what could be causing this?

Mass export all images as individual JPEGs?

$
0
0

Hi! I am new to Indesign. I have a file that contains images with Photoshop clipping paths. I want to export all the clipped images in a folder. I have tried doing the "Copy Links To" and it successfully exported the original images. However, I do not want the original images but the clipped images instead. Is there a way for me to export all the clipped images as JPEG or TIFF and not the original linked image? In short, I want to export the images without their background. I hope I'm making sense. I have about 800-1000 images so a batch processing method would be highly appreciated.

 

I actually found a way to export the images the way I want them to be. I just need to click the image container (not the image), go to File>Export and then export it as JPEG. In the pop up window, I choose export selection, maximum quality, and 2400 resolution. It exports the images the way I want them to be. But I have to do this one by one. I just have two concerns:

1. Is there a way for me to do this by batch? Like select all the image containers and export them one by one automatically?

2. Is there a way to automatically name the saved files according to the original image name?

 

Thank you for your help!

Viewing all 15932 articles
Browse latest View live


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