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

extract pages to individual .indd files

$
0
0

Looking for a way to extract all pages in a .indd document (used data merge to create pages)

Now I need each page as an individual InDesign file...

thanks!


firstLineIndent picks up different value in CC

$
0
0

I'm having an issue with this script:

 

app.findTextPreferences.firstLineIndent = app.selection[0].firstLineIndent;

 

It picks up the correct value in CS6 just fine, but when I run it in CC, it picks up a completely different value. I've tried setting #target to "InDesign-13," but it hasn't made any difference. Is there anything I can do to fix it? It's such a simple line of code that I'm at a loss as to what more I can try.

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

Split long text into multiple text frames by PARAGRAPH breaks, not by line breaks

$
0
0

I am creating a catalog for an auction. Right now I have a long table in Word, where each row is one item in the catalog.

I know how to place the table in InDesign and convert it into text so that each row is its own paragraph (click on table >> convert table to text).

Now, I would like to run a script so that each paragraph becomes its own text box.

I tried using the script by Jongware mentioned on this thread (https://forums.adobe.com/thread/652308), but it breaks up each LINE into its own text box, not each paragraph.

One solution that has worked for me previously is to manually adjust the text boxes until every paragraph is in a separate box, then use the SplitStory script to unthread all of them. However, the catalog has over 100 items in it so that is extremely time-consuming. Is there a way to separate each paragraph into its own text box automatically?

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...

Check if a file exists in network dir (JS)

$
0
0

I've found an old post that has pointed me at:

 

if (myFile.exists){

alert("File Exists");

}

else

alert("File doesn't exist");

 

The problem is that when I use the path  macname/volumes/dir/folder/folder/file.indd (which was created from variables) as myFile the script doesn't find a file that I know exists. All I get is the "File doesn't exist" alert.

 

Do I need to define myFile as being a string?

 

I'm still fumbling my way around JS, and converting Applescripts to JS to work cross-platform. Thanks in advance....

Automatically create hyperlinks with a script

$
0
0

Hello

 

I have created a catalog in indesign with about 8000 Articles in it. The Cataloge looks similar to this:

Article #
Name
Price
8762903Article 118 $
8456901Article 27 $

 

Later I want to export the whole catalog as a PDF Document and want that my customers can click on every article number in the PDF Document and are getting redirected automatically to my online shop. The Shop URL looks like this: https://www.testshop.com/*ArticleNumber*

 

Can someone please help me creating a Script, which automatically searches in the indesign Document for all Article Numbers (Always starting with the number 8 and then have 6 more digits) and add a hyperlink to the correct URL (https://www.testshop.com/*ArticleNumber*)?

 

I really hope someone could help me, as I am trying to solve this problem for days.

 

Thank you so much!

Grep function changes "Name Surname" in "N. Surname"

$
0
0

I'm looking for Grep function that changes (in a list of 100 names and surnames) the name with the name initial pointed.
Example

Robert Redford >> R. Redford

Tom Cruise >> T. Cruise

 

Thank you!

 

 


Read a line from txt file

$
0
0

Hello all,

I need to know how to read whole lines from any txt file. E.g. I have this in txt file:

 

testline1

testline2

testline3

 

and I need to read only line 2 (text "testline2").

 

I know how to read whole file:

 

var file = File(app.activeScript.parent.fsName + '/test.txt');
file.open("r");
var str = file.read(); // whole content of "test.txt" is now in variable "str"
file.close();

 

but I don't know how to read ONLY e.g. line 2. Can you help me with this someone please?

 

Thanks very much in advance

Importing a .csv or .txt file into InDesign using Javascript to alter page attributes (and more).

$
0
0

Hi there,

 

Semi-new to scripting in general, very new to scripting for InDesign.

 

What I've been trying to figure out is exactly (and I do mean exactly!) how to import a .csv or a .txt file into a Javascript script, containing values that I can then designate to variables, and in turn use those variables to create a new InDesign document. I'd prefer to do this all from within the script… not importing anything using the DataMerge feature.

 

For example, the .csv file might look like this:

 

Height, Width, Margin, Bleed, AllBleed

17, 11, .5, .125, true

 

Then the script would import this file, and from the data it gets, creates the following variables:

 

var myHeight = Height;

var myWidth = Width;

etc.

 

From which the script would then create my document using myHeight, myWidth, myMargin, etc.

 

How would I go about doing this? And as a bonus, how would I do this for multiple documents (when the .csv file has multiple records)?

 

Thanks for any assistance on this!

 

-jOE

Script for shrinking overset text?

$
0
0

I use data merge to create labels for guests attending functions. Usually this is around 500-1000 labels at one time. I usually set my text frame on the template page for a large point and then shrink it horizontally (I do this to minimize the number of pages I have to manually edit for overset text). I still get some names where they are long hyphenated names that create overset text.

 

Is there a script available where it will recognize there is overset text and then shrink the text down either by decreasing the point size or adjusting the horizontal spread of the text (maybe making it 100% to 80%)?

Run .bat file with arguments?

$
0
0

Hi,

 

   I need to run the .bat file with parameters/arguments in Adode Indesign JavaScript. "File.execute()" executes the file using the appropriate application.It executes the .bat file suceessfully.But I am unable to pass the arguments.I need to execute the command like

Eg : test.bat parameter1 parameter2

 

var myFile=new File("c:\\test.bat");

myFile.execute();

 

The above statements works fine. Is it possible to execute the with parameters. Please suggest the solution to above problem.

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]

 

 

.

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

How do you select a layer by name using Javascript?

$
0
0

How do you select a layer by name using Javascript?

 

You can do this in Applescript using this code:

setactive layerofactive windowtolayer "Layout" ofmyDocument

 

I can't figure out the correct syntax in Javascript.

 

Anyone know how to do this?

 

Any information would be greatly appreciated,

adobeJavaScripter


Mail Merge to multiple unique PDFs with unique names from one template

$
0
0

I can't seem to find any info on this scenario which I thought would be something a ton of people use. I have a template. I want to use a CSV file to export the template as multiple PDFs. This is because each PDF output will have a separate address phone number and be shared with an office that doesnt need any of the either info that I am importing from the csv. I don't want them all to "merge" into one PDF.

 

It would also be nice to be able to have each of the first cells used in the name. so it ends up being "template_brampton.pdf" "template_toronto.pdf" etc.

 

Thoughts on how to do this?

extract pages to individual .indd files

$
0
0

Looking for a way to extract all pages in a .indd document (used data merge to create pages)

Now I need each page as an individual InDesign file...

thanks!

Help with placi

$
0
0

Help with opening a specific folder and placing a InDesign snippet file (idms)

 

I’ve got one script that will place a particular graphic…but I’m having trouble getting my script to open a particular folder and allow me to select which file I want to place.

 

In addition, I’d like the file to automatically place on page A2 in a newspaper document at x=0.347 in and y=1 in.

 

Here is what I have so far.

It opens the folder, but when I select the file, nothing happens.

 

var myDocument = app.activeDocument, 

myPage = myDocument.pages.item(0);

 

var dir = Folder("/C/Users/lpitts/Downloads");

var files = dir.openDlg('This is always the same folder?','',true);

myStory = myPage.place();

 

Obviously, I'm missing a command or something else, but everything I've come up empty with everything I've tried so far.

I’m new to scripting, so I’m flying blind…

Thanks for any help or advice.

 

Larry

app.documents.length returning false positive

$
0
0

I've read here and elsewhere that 'app.documents.length > 0' is the correct way to check if there are open documents, but it seems to be failing me…

 

Here's the scenario:

  1. I have a function that starts by testing 'app.documents.length > 0'
  2. If that passes, it tries to access 'app.activeDocument'.

 

Now normally, that function works perfectly, as you would expect. BUT it fails spectacularly if:

  1. I call the function from an 'afterContextChanged' listener, and
  2. I close a document in InDesign.

 

Under these conditions, InDesign throws the alert:

 

"An attached script generated the following error:

No documents are open.

Do you want to disable this event handler?"

 

As best I can tell, the problem is that at the moment 'afterContextChanged' is triggered, 'app.activeDocument' has been nullified, but the 'app.documents' container hasn't yet got the memo, and returns a false positive. i.e. 'app.documents.length > 0' returns true when there is no active document.

 

A bug in Adobe's API? Or a lack of understanding on my part?

Get textFrame's Tag/Label through script

$
0
0

Hello everyone,

 

I'm really sorry if this has already been asked, I have found discussions that touch on it, but haven't found any suggestions or solutions.

 

I am a web developer, with no inDesign experience, our graphic designer uses it to build our flyers.

We have been talking about translating the flyers to another language, and I have been working on making them interactive (with an image map)on our website.

If I'm going to suggest we revise the flyer structure for automating the translation, I'd like to also handle the image mapping (pulling image + area coordinates)

 

The thought was to write a js script that will pull the text frames from the file so I can work with them using other scripts to translate, get coordinates, etc.

 

I have more or less succeeded in doing this using the textFrame's name.
I'm currently renaming each item in the Layers window with a key-value naming structure (000-000-000|Title, 000-000-000|Description) and then splitting the name by '|' to get the product code [0] and the textFrame 'tag' [1]. Then I can run the 'tag' portion of the content through a translation script, or coordinate script as needed.

 

But there are dozens of pages with numerous products on each page, and multiple fields (title, description, price, quantity, product number) for each product.
I don't want to propose our designer meticulously rename thousands of elements.
I have found the Tags window to be much quicker to associate a type to each textFrame. But I haven't been able to work with the tags through script...

 

From what I've read, CS5 and later doesn't allow you to get a tag/label through scripting.

Is this true? Is anyone aware of any way around it?

 

 

-TLDR-

I have thousands of text (and image) elements in a InDesign file, and I would like to pull their contents out with a script and process them depending on the text field's type (product description, image, price, etc.).

Tags/Labels seem perfect, as I could just loop through all textFrame elements, and say if has tag 'description' then pass into translate(), if image getCoords().
And they are rather quick to associate with elements.

 

But from what I've read CS5 + doesn't allow you to work with tags through scripts in this way.

 

 

Any suggestions to accomplish this without working with the textFrame's names? (I'd like to avoid adding that much work to our graphic designer's monthly process)

 

If it is relevant I'm using inDesign CC 2017  V- 12.1.0.56

 

Thanks in advance for any input or direction you can provide. InDesign is not something I am familiar with :/

Viewing all 15932 articles
Browse latest View live


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