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

Include remote .js-file in script-file (and use it's variables)

$
0
0

'm trying to access a remote .jsfile within an inDesign script to use it's variables. I found functions for including js-files locally but haven't found a good way to include.

http://remote-site.com/test.js:

var testVar ="it works!";

myscript.js, including locally (working):

app.doScript(newFile("/Users/Popmouth/test.js")); alert(testVar);

myscript.js, including locally including remotely (not working):

app.doScript(newFile("http://remote-site.com/test.js")); alert(testVar);

Error message

I also found this snippet, this alert works (alerts the content of the file, i.e. "var testVar = "it works!;") but I don't know how to use the vars in my alert function below:

var HTTPFile = function (url,port) {

 

 

          if (arguments.length == 1) {

 

 

                    url = arguments[0];

 

 

                    port = 80;

 

 

          };

 

 

          this.url = url;

 

 

          this.port = port;

 

 

          this.httpPrefix = this.url.match(/http:\/\//);

 

 

          this.domain = this.httpPrefix == null ? this.url.split("/")[0]+":"+this.port :this.url.split("/")[2]+":"+this.port;

 

 

          this.call = "GET "+ (this.httpPrefix == null ? "http://"+this.url : this.url)+" HTTP/1.0\r\nHost:" +(this.httpPrefix == null ? this.url.split("/")[0] :this.url.split("/")[2])+"\r\nConnection: close\r\n\r\n";

 

 

          this.reply = new String();

 

 

          this.conn = new Socket();

 

 

          this.conn.encoding = "binary";

 

 

 

 

 

 

 

 

          HTTPFile.prototype.getFile = function(f) {

 

 

                    var typeMatch = this.url.match(/(\.)(\w{3,4}\b)/g);

 

 

                    if (this.conn.open(this.domain,"binary")) {

 

 

                              this.conn.write(this.call);

 

 

                              this.reply = this.conn.read(9999999999);

 

 

                              this.conn.close();

 

 

                    } else {

 

 

                              this.reply = "";

 

 

                    }

 

 

                    return this.reply.substr(this.reply.indexOf("\r\n\r\n")+4);;

 

 

          };

 

 

}



var hyle = new HTTPFile("http://remote-site.com/test.js ");

 

 

alert(hyle.getFile());

 

 

hyle.getFile();

 


Override elements by script problems

$
0
0

I need to override elements by script and have them end up at the same place they were in master. Now it overrides and puts them to the new page but it changes their position. Here is my function:

 

function loadPagesAndOverrideElements(document, csvData) {

    // add pages defined in CSV and correct layout

    for (var i=0; csvData.numberOfRows>i; i++) {

        var masterSpread = document.masterSpreads.itemByName(csvData["master"][i]);

 

 

        document.pages.add();

        document.pages[i+1].appliedMaster = masterSpread;

        var allItems = document.pages[i+1].appliedMaster.pageItems.everyItem().getElements();

 

 

        for(var j=0;j<allItems.length;j++){

            try {

                allItems[j].override(document.pages[i+1]);

            } catch(e) {

                // alert(e);

            }

        }

    }

 

 

    document.pages[0].remove();

 

 

    return document;

}

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

Batch Relink, Save, and Export

$
0
0

Hello,

 

I'm looking for a script to help automate the relinking, saving, and exporting of  about 100 InDesign files. I need to relink the background (which is the same format in each file), save the updated version, and then export to PDF with bleed and crop marks. Does anyone know of a script/quick method for doing this?

How to align staticTexts

$
0
0

Hi,

Please reply if you know how to align staticTexts.

I tried

1. staticAlignment = Left_Align

2. justify:"left"

3. Justification.leftAlign

4. alignment = Left_Align

but no luck so far.

here is what I am doing

 

with(myDialog)

{

     with(dialogColumns.add())

     {

          with(borderPanels.add())

          {

               with(dialogColumns.add())

               {

                    // This is right aligned which is okay.

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

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

               }

               with(dialogColumns.add())

               {

                    // need to align this to Left

                    staticTexts.add({staticLabel:SampleVal1});

                    staticTexts.add({staticLabel:SampleVal2});

Find colored text then delete/remove it from text frame.

$
0
0

Hi people,

 

The company I work for receives content written in a word document which then needs to be transferred into InDesign so that it can be formatted and designed by graphic designers. Within the word document the author will have the content in black and any instructions to the designers written in red. At the moment designers copy and paste the content into an InDesign document leaving behind the red instructions. As the designers have to do this many times over I was wondering if anyone would be able to educate me on how we could write a script to remove any red text from the text frame after the document has been placed in InDesign.

 

Any help would be greatly appreciated!

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

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


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

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

Converting a text box to an anchored object nearest the main text frame

$
0
0

Good morning.

I have trouble.

There are many text boxes in one document.

I want to convert it to an anchored object at the nearest distance of the text frame where the text box is located.

If you have a few textboxes, I can convert them to anchored objects by dragging and dropping them, but there are hundreds of textboxes, so I need a script that can automate this.

I post a single image to help understand.

The text box contains a sentence with a table of contents of 1,2,3 in the image.

I want to convert it to an anchored object.

 

 

I hope that someone presents a wise solution.

 

image sample.png

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!

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?

exportFile() and ICML : loop issues

$
0
0

Hi,

i'm attempting to export an array to ICML files with a "for loop" in which i update "myStory.contents" with my array entries, then export the story to ICML file. However, the script seems to break at the end of the export. Thing is, my script works perfectly well with txt and rtf files. Has someone an idea about this issue and the way to work it out ? I guess this "problem" might have to do with the ICML file auto-linking to the story object (but why ?)...

 

Thanks

Adrien

Fetching fonts from TypeKit with AppleScript

$
0
0

Is it possible for AppleScript to automatically fetch needed fonts from TypeKit for InDesign CC? Moving from CS6 to CC 2017, this is becoming a problem because a script batch processes books and magazines to output overnight the PDFs for print and digital publications, but an increasing number of documents are tagged for manual processing in the morning because a designer used a TypeKit font that must be manually loaded onto the Production Mac before it can export the PDFs. I've hit a roadblock since a search for the word "typekit" in ID's AppleScript dictionary found no results.

 

As a backup plan, is there a simple way for an AppleScript to parse ID docs to gather a list of TypeKit fonts used before they're queued for output?

 

Thanks much for any advice -- Rick


How to extend/add additional functionality (to) an InDesign class like Cell

$
0
0

Hello,

I am trying to add some extra functionality to every instance of e.g. the Cell 'class' of InDesign using Javascript. I started doing something like this:

 

Cell.prototype.newFunction = function() { ....... }

 

which works fine: it is now possible to call newFunction() on every instance of Cell.

But now I would like to let this function (that I've added to the prototype chain of Cell like shown above and thus is also available for an 'instance' of Cell) use a 'variable' that is specific for every Cell instance, e.g.:

  

Cell.prototype.getSuperValue = function ()

{

if (this._cachedValue === undefined)

{

this._cachedValue = 3; // doing some incredible calculations that take some time

}

return this._cachedValue;

};

  

The this._cachedValue should be a attribute of the Cell instance. So if I take to cells from a Table and I call getSuperValue() on them I can get two different values that are specific for every instance of Cell.

 

  

Thanks a lot in advance!

 

  

P.S. although I am quite new to Javascript I know there are no classes in Javascript and that Cell is an object. But I thought explaining it like this would make it more clear?

Find string of paragraph numbering

$
0
0

So I've made a script to change data in multiple tables. I want to target each table by looking for an index-number. This index-number is generated with a Paragraph Style Bullets & numberings (then using just a space to print that)inside a table cell. I wonder, is there anyway to actually target that value?

 

Here's a rough example:

 

Table oneindex_0
Value 1value 2
Value 3Value 4

 

Table Twoindex_1
Value 1value 2
Value 3Value 4

 

 

Here's my code that works with normal text in a cell:

 

app.findGrepPreferences.findWhat = "index_0"; // Find table with index  

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

Use actual page size in AppleScript, not document setup size.

$
0
0

Hi all,

 

Hope somebody could point me in the right direction...

 

I have a droplet app written in AppleScript. It looks for the page size of the documents dropped and uses that info. Just for testing I have a dialog at the end which returns this.

 

The problem;

The app only returns the document size, as in the size displayed in the 'Document setup' window. I need to use the actual page size, as a large number of my clients use the page tool to adjust the page sizes. I need it to always use the actual page size.

 

Has anyone run into a similar problem?

 

My code is below, thanks in advance for any help

 

 

on open mgItems

  repeat with mgThisItem in mgItems

  tell application id “com.adobe.InDesign”

  try

  open mgThisItem

 

  tell active document

 

  my get_documentSizes()

 

  tell document preferences

 

  tell document preferences

  set overallwidth to page width

  set overallHeight to page height

 

  end tell

 

  end tell

 

 

 

 

 

  end tell

 

  close active document

 

  on error

  -- decide what kind of error handling you want to include if the file won’t open

  end try

  end tell

  -- rest of script for email processing here

  end repeat

  display dialog overallwidth

end open

Impose Script

$
0
0

Hi everyone!

I have been dealing with a problem for a while. Maybe someone could give me a help.

I have a system that generates personalized books. My site creates .xml files. I import those .xml into a .indt template and then generate a .indd and a .pdf file.

Then I send those .pdf to a printer company.

Unfortunately, printer demands imposed .pdf files. I know that he is supposed to make imposition, but the truth is that he does not have the necessary drivers and that's the only company that accepted me as a client (I am a really small client).

I need to make this process as automated as possible so I designed a script that:

1. Read xml in a folder (OK)

2. Open the template (OK)

3. Import xml into template, generating a indd (OK)

4. Print booklet (NOT OK).

 

At this moment, my script handles 1-3 but I have to manually "print" every booklet. It's a problem, because I have to keep "looking" to computer waiting for the the print booklet process.

 

I have tried 3 different approaches:

a. Use printbooklet() function, but it only generates .ps automatically (printBookletPrintPreferences.printFile only accepts post script files). I still need to type the file name for every file.

b. Reorder pages and print spreads to simulate imposition (it does not work, because each 2- page spread share the same background image).

c. Generate a regular pdf than reorder pages and re-generate pdf (I couldn't find a way to manipulate pdf in indesign).

 

So, here I am. I really need to read a set of .xml and generate imposed pdf automatically. I am not a expert in InDesign or scripting. So thank you in advance for your patience. Any help will be highly appreciated.

 

Regards,

Roberto

Viewing all 15932 articles
Browse latest View live


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