Quantcast
Channel: Adobe Community: Message List - InDesign Scripting
Viewing all 37788 articles
Browse latest View live

Re: find a column widh

$
0
0

var column = app.activeDocument.stories.everyItem().tables.everyItem().cells.everyItem().getElements() ,linewidth = [];

var lines = column[i].lines;

linewidth.push(lines[0].endHorizontalOffset - lines[0].horizontalOffset);

alert(Math.max.apply(null,linewidth));


Re: Align Inline Equation to Baseline

$
0
0

Hi,

 

  Sorry.. When the document contains missing links its throwing this error.

Re: find a column widh

$
0
0

Hi VeluVK,

 

try the below js code, you can change the measurement values what you need (picas, points, mm, etc.,).

 

var myDoc = app.activeDocument;
var myTables = myDoc.stories.everyItem().tables.everyItem().getElements();
for (i =0; i<myTables.length; i++){    var myFirstColumn = myTables[i].columns[0];    if(myFirstColumn.width <=200){// based on your column width checks        alert(myFirstColumn.cells.everyItem().contents);        };    }

 

 

thx,

csm_phil

Re: Need help installing first .jsx script for InDesign CS4 6.0.6 under Windows 7 Pro SP1 (64 bit)

Re: Prepend XMLElements and adding children?

$
0
0

For your second question, although I have not found a solution to this problem myself either, I've recently been struggling with the same.

 

What (I think) I've found so far is that the difference lies in whether an XML element is placed in the document (as, in your case, it would be when you use 'yourSelection'), as opposed to a parent and child element that both only appear in the XML structure. I think this has something to do with an element automatically being added to a parent Story element when placed in the document, and that screwing up the structure in some way. It's just basic symptom diagnosis though, there's probably someone with a much more logical explanation for all this.

Re: Need help installing first .jsx script for InDesign CS4 6.0.6 under Windows 7 Pro SP1 (64 bit)

$
0
0

Hi csm_phil,

 

Thanks for taking the time to reply.

Both of those links say to right click on the folder that appears in the panel, and choose "Reveal in Explorer."

As I mentioned above, I already tried that. It doesn't work in my case.

Re: Align Inline Equation to Baseline

$
0
0

@Sudha – what did you expect?


The script is trying to open the linked EPS file and reading out the first PostScript comment starting with the string "%%Baseline" to extract the substring after a whitespace followed by a substring that is not a whitespace.

 

What can go wrong with that:
1. There is no EPS file properly linked; so it cannot be opened.

2. If it is properly linked, the EPS file does not contain a readable PostScript comment

3. The PostScript comment is there, but does not contain a substring that could be converted to a number.

 

So you should test for all the above cases and react with an alert or something.

 

Uwe

Re: Align Inline Equation to Baseline

$
0
0

Hi,

 

   I thought its work for all images without checking whether its missing or not. But the image is missing, as you said we cant read tat file.

 

   So we can check the 1st point by missing links... how to check the point 2 and 3???

 

- Sudha K


Re: Re: Align Inline Equation to Baseline

$
0
0

@Sudha – do something like that:

 

try{    var baseline = fs.match(/%%Baseline\s+(\S+)/)[1];    }catch(e){        //Give alert:        alert("No match found:"+"\r"+e.message);        //Exit and end the script at this point:        exit();        };

 

Uwe

Re: Align Inline Equation to Baseline

$
0
0

Hi,

 

Ok thank you...

 

is it for both point 2 and 3???

Re: Re: Align Inline Equation to Baseline

$
0
0

@Sudha – it is basically for the case where fs.match() is causing null.

 

If a substring is returned you could test for NaN (Not a Number) before assigning it as a value for the anchorYoffset property of anchoredObjectSettings of your selection.

 

if(isNaN(Number(baseline))){    alert("Found substring cannot be converted to a number.")    exit();    };

 

 

Uwe

Re: Align Inline Equation to Baseline

$
0
0

HI,

 

Thank you...

 

When im using this logic, some of the inline objects are aligned correctly to baseline. Some is not aligned correctly... its moved down to baseline.  Don't know the reason...

 

Before run the code the image was like this.

bef.png

 

After run the code the image is like this.

after.png

 

I run the code for all objects in document.  Some objects aligned correctly. Some having this problem.  How can i fix this issue??

 

How the value baseline in postscript comment is related to inline value of anchor object settings?? Can u pls explain this???

 

- Sudha K

Re: Prepend XMLElements and adding children?

$
0
0

Sounds like a bug to me - especially as the add() returns NULL rather than throwing an error.

A workaround could be something like this:


if( xe.parentStory instanceof XmlStory ) {

  x1 = xe.parent.xmlElements.add("x1");

  x1.move(LocationOptions.BEFORE,xe);

} else {

  x1 = xe.parent.xmlElements.add("x1",xe.storyOffset);

}

Re: find a column widh

$
0
0

Why do you guys make it so complicated? All VeluVK want to know is how to find the width of a column. That's

 

myTable.columns[0].width

 

If you think he should have checked the object model for himself, then say so.

Re: Set top and bottom inset spacing values in Text Frame Options via jsx script

$
0
0

app.textFramePreferences.insetSpacing = ['0p2', 0, '0p2', 0];


Re: Set top and bottom inset spacing values in Text Frame Options via jsx script

Re: Re: find a column widh

$
0
0

Hi Peter,

 

As you suggest, I just modified the js code. thanks for highlighted this!!

 

1. directly to get the 1st column width for every tables.

var myDoc = app.activeDocument; 
var myTables = myDoc.stories.everyItem().tables.everyItem().columns[0].width;
alert(myTables)

 

2. here loop all the tables and get the 1st column width.

var myDoc = app.activeDocument; 
var myTables = myDoc.stories.everyItem().tables.everyItem().getElements(); 
for (i =0; i<myTables.length; i++){     var myFirstColumn = myTables[i].columns[0].width;    alert(myFirstColumn)    } 

 

 

thx,

csm_phil

Re: Align Inline Equation to Baseline

$
0
0

@Sudha – no, I cannot explain this, because I do not know the PostScript code in your EPS files. For me it seems, that assigning just the negative of a number that is used in a PostScript comment may be too simplistic to get what you want.

 

Uwe

Re: Align Inline Equation to Baseline

$
0
0

Oh, and looking at your example: Why did you run the code on this?

As far as I can see the position of the equation was good before running the code…

 

Uwe

Re: Re: Line number of selected text from footnote

$
0
0

Number of the line of the footnote reference: get the insertion point of the footnote in the main text:

 

try{    if (myText.parent instanceof Footnote) {          myText = myText.parent.storyOffset;    }    var myTF = myText.parentTextFrames[0];    . . .

 

Number of the line in the footnote: you can't use the text frame, clearly, so you need to use the range from the beginning of the note. That is, is the note starts on the same page. If the note starts on an earlier page, you have to make another decision: do you want the number of the line in the note on this particular page or the number from the beginning of the note? Both would be useful, you will say -- so a good task for you to figure out.

 

Peter

Viewing all 37788 articles
Browse latest View live


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