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

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


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?

Paragraph search

$
0
0

Is this possible to find the frist instance of paragapah in every page.

"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);

                }

 

            }

      }

Bridge talk for InDesign CS4/CS5

$
0
0

Hi, I am looking for any documentation I can find for Bridge talk scripting. So far nothing comes with the search. Does anyone know any sources.

 

Thank you very much.

Yulia

Combining or Merging Indesign Files (IDML/INDT)

$
0
0

Greetings,

 

I would like to inquire about a possible performance problem regarding combining multiple IDML / INDT files or copying pages via Indesign Server Scripting API.

Note that we are using Indesign Server CS6 (with latest 8.0.2 update).

 

Currently, we are using the following line to merge multiple indesign documents (IDML/INDT)

document.pages.everyItem().duplicate(LocationOptions.AFTER, baseDocument.pages[lastPageIndex])

 

Above line performs what is needed (textframes are threaded, etc), however there is a possible issue with its performance which degrades horribly especially after several merging operations and if there are several pages in the base document or the document to be copied (though the performance is more affected when the document to be copied has many pages)

 

Testing done:

#1 For the below test, Notice that the merging is not constant and degrades per minute (performance may possible degrade when using a larger document)

 

start

end

time elapsed for pages.everyItem.duplicate

 

operation done

with a base of 42 page INDT document

12:13:33

12:15:28

0:01:55

 

add 42 page INDT file

12:15:29

12:18:35

0:03:06

 

add another 42 page INDT file

12:18:37

12:22:53

0:04:16

 

add another 42 page INDT file

12:22:54

12:28:15

0:05:21

 

add another 42 page INDT file

12:28:17

12:34:30

0:06:13

 

add another 42 page INDT file

 

 

TOTAL

 

 

 

 

0:20:51

 

 

 

with a base of 42 page IDML document

12:13:58

12:16:44

0:02:46

 

add 42 page IDML file

12:16:56

12:20:59

0:04:03

 

add another 42 page IDML file

12:21:11

12:26:21

0:05:10

 

add another 42 page IDML file

12:26:35

12:32:39

0:06:04

 

add another 42 page IDML file

12:32:50

12:40:06

0:07:16

 

add another 42 page IDML file

 

 

TOTAL

 

 

 

 

0:25:19

 

 

 

Time elapsed is 20 minutes for INDT and 25 minutes for IDML. it adds ~1 minute for each document added (for a 42 page, this duration may increase when no of pages increase).

 

#2 For below test, we noticed that INDT seems to perform faster than IDML (though it is larger by 10x and is a binary file)

 

 

with a base of 838 page IDML document

14:30:44

14:55:40

0:24:56

 

add 42 page IDML file

 

 

 

 

 

 

 

 

 

 

with a base of 838 page INDT document

15:14:55

15:23:40

0:08:45

 

add 42 page INDT file

 

#3 For below test, notice that the merging degrades by several minutes even if you just increase the number of pages.

Notice that we added the documents according to increasing no of pages as we found out that it performs significantly faster than not (saved several hours)

I also incorporated the doc.save and gc calls but it still doesn't help reduce the whole merging process to several minutes. (still takes 11 hours just to merge 33 documents with total of 1046 pages)

Note that we also checked binary merging (merging small files first but the resulting time is much larger than above)

 

with a base of 1 page IDML document

15:58:45

15:58:52

0:00:07

 

add 1 page IDML file

15:58:53

15:59:00

0:00:07

 

add 1 page IDML file

15:59:01

15:59:08

0:00:07

 

add 2 page IDML file

15:59:09

15:59:18

0:00:09

 

add 2 page IDML file

15:59:19

15:59:29

0:00:10

 

add 3 page IDML file

 

 

 

 

perform $.gc  and doc.save into temp IDML

15:59:35

15:59:42

0:00:07

 

add 4 page IDML file

15:59:44

15:59:52

0:00:08

 

add 6 page IDML file

15:59:54

16:00:05

0:00:11

 

add 6 page IDML file

16:00:08

16:00:21

0:00:13

 

add 6 page IDML file

16:00:23

16:00:49

0:00:26

 

add 7 page IDML file

 

 

 

 

perform $.gc  and doc.save into temp IDML

16:00:53

16:01:03

0:00:10

 

add 7 page IDML file

16:01:05

16:01:19

0:00:14

 

add 8 page IDML file

16:01:22

16:02:18

0:00:56

 

add 10 page IDML file

16:02:22

16:04:12

0:01:50

 

add 17 page IDML file

16:04:17

16:06:41

0:02:24

 

add 19 page IDML file

 

 

 

 

perform $.gc  and doc.save into temp IDML

16:06:50

16:09:14

0:02:24

 

add 20 page IDML file

16:09:19

16:12:31

0:03:12

 

add 20 page IDML file

16:12:37

16:15:53

0:03:16

 

add 21 page IDML file

16:15:59

16:21:00

0:05:01

 

add 26 page IDML file

16:21:07

16:27:25

0:06:18

 

add 27 page IDML file

 

 

 

 

perform $.gc  and doc.save into temp IDML

16:27:40

16:38:28

0:10:48

 

add 37 page IDML file

16:38:38

16:50:42

0:12:04

 

add 39 page IDML file

16:50:55

17:08:09

0:17:14

 

add 42 page IDML file

17:08:21

17:28:39

0:20:18

 

add 44 page IDML file

17:28:55

17:58:32

0:29:37

 

add 52 page IDML file

 

 

 

 

perform $.gc  and doc.save into temp IDML

17:58:58

18:26:26

0:27:28

 

add 52 page IDML file

18:26:42

19:11:57

0:45:15

 

add 63 page IDML file

19:12:16

20:08:49

0:56:33

 

add 64 page IDML file

20:09:09

21:13:22

1:04:13

 

add 67 page IDML file

21:13:59

22:39:28

1:25:29

 

add 67 page IDML file

 

 

 

 

perform $.gc  and doc.save into temp IDML

22:40:15

0:35:17

1:55:02

 

add 84 page IDML file

0:35:48

3:30:53

2:55:05

 

add 98 page IDML file

 

 

TOTAL

 

 

 

 

11:26:36

 

 

 

Notice that I have already added $.gc and doc.save per 5 documents however the effect is lost/not significant around the 4th/5th time.

 

Please confirm if there is something that can be done to resolve above Indesign's performance for merging / copying pages from one document to another.

or suggest alternative code or some setting that we may have missed.

 

Thanks

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

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)


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?

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

With CS3, some things have changed

$
0
0
Let's use this topic to record changes that are likely to affect a working script. As I did in the CS2 comparable topic, I'll add an index here in the topic title when the list is long enough (and I have the time).

How can I get a total page count of a PDF before placing every page in the PDF?

$
0
0
Before the [long] spiel, I'm using javascript in InDesign CS3.

I'd like to create a script that places a multiPage PDF in any number of different impositions. (saddle stitch, 4up signatures, 16up signatures etc.)

I've easily created a script that iterates through a PDF and places it into a new document as (4,1|2,3), (8,5|6,7) etc, which works for printing in duplex, folding each page in half, and gluing the resulting spines to make a simple thick book (for PDFs with more than, say, 64 pages).

However, the next step is to re-write the script to create a saddle stitch document (16,1|2,15), (14,3|4,13) ... (10,7|8,9). For this I need to know how many pages there are in the PDF before I start placing the PDF pages, and then making the new document [int((PDFpages+3)/4)] pages long.

Is there a simple way to get the count of PDFpages without going through a loop and placing the next page from the PDF until the placed page number equals the first page number?

This way seems wasteful:

var totPDFPages = 1;
app.pdfPlacePreferences.pageNumber = totPDFPages;
myPDFPage = sheetFront.place(File(srcPDF), [0,0])[0];
var pdfFirstPage = myPDFPage.pdfAttributes.pageNumber;
while (doneCounting == false) {
totPDFPages += 1;app.pdfPlacePreferences.pageNumber = totPDFPages;
myPDFPage = sheetFront.place(File(srcPDF), [0,0])[0];
if (myPDFPage.pdfAttributes.pageNumber == pdfFirstPage) {
totPDFPages -=1;
doneCounting = true;
alert("PDF has " + totPDFPages + " pages!");exit();
};
myPDFPage.remove();
};

NB. Javascript above *hasn't* been run, but should look similar once debugged.

The only thing I've though of to relieve the sheer duplication of placing the PDF twice (once for the count, and once for the imposition), is to create an array of impoPages[counter]=myPDFPage, and then shuffle the pages referenced by the array to the correct sheet and position.

It'd be much easier to be able to assign pageCount = File(srcPDF).pageCount !!!

Thanks for any help/tips or even a simple "What are you smoking, man!?"

Cheers,
Jezz

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

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!

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


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

ScriptUI for dummies

$
0
0

I've been putting together a text on ScriptUI, to a large extent to clear up things for myself (hence the title!). It's an introduction to ScriptUI, much of it very basic, here and there going into some detail. It's not a finished product, and comments, suggestions, and corrections are welcome. If you're interested, you can find the PDF file here: http://www.kahrel.plus.com/indesign/scriptui.html

 

Peter

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?

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()

ScriptUI : edittext live modifications problem

$
0
0

Hi,

I set a scriptUI interface.

 

http://i.imagehost.org/0754/Image_1.png

I have two buttons :

     - one has to add a carriage return on the edittext field

     - one has to add tab.

I am using textselection property of the edittext object.

On Mac it works very fine.

On Windows, it just go crazy. Sometimes, it just ignores the click, other times, it adds the element unexpectingly.

ie tab or carriage return are placed everywhere but where I want it.

What do I do wrong ?

TIA Loic

Viewing all 15932 articles
Browse latest View live


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