Copy link to clipboard
Copied
Hi everybody, sorry for my very bad english (french guy! logical). I hope you see what I'm looking for.
I'm scripting (javascript) an exporting script of every articles from a multi-pages indesign script.
In fact I could have one or more article in one file, every one of them is on an separate xml element. for each I have to export an xml file named with, first, the page number where appears the xml element, second, the number of exported article.
I'm success the second purpose, but not the first.
Someone have an idea ?
Hi kazegonzo,
Please try the below js code, I have access the doc/article/titre tag because the doc not placed into the pages, you placed the titre tags so i access the titre tag and get the page number.
var myDoc=app.activeDocument;
var root = myDoc.xmlElements[0];
var docTag = root.evaluateXPathExpression('//doc//article//titre');
for(i=0; i<docTag.length; i++){
var docPos = docTag.xmlContent.insertionPoints[0].parentTextFrames[0];
alert("Page: "+docPos.parentPage.name);
}
thx,
csm_p
...Copy link to clipboard
Copied
Hi,
I am not clear with your question, but if you want to find the page number of an xml element. The below link will help you:
http://forums.adobe.com/message/5308008#5308008
Vandy
Copy link to clipboard
Copied
Hi vandy88, thanks and sorry for the late answer.
your answer is a great help for me, but it doesn't work. I get the following error message "undefined is not an object" about this line "alert(figCitationPage.name);"
Copy link to clipboard
Copied
Which InDesign version you are using, if it is below cs5 the code wont work, then u need to work out in an alternate way
Vandy
Copy link to clipboard
Copied
I'm using InDesign CS5.5
thx
Kazegonzo
Copy link to clipboard
Copied
Try this,
var myDoc=app.activeDocument;
var root = myDoc.xmlElements[0];
var docTag = root.evaluateXPathExpression('//doc');
for(i=0; i<docTag.length; i++)
{
var docPos = docTag.insertionPoints.lastItem();
var docFrame = docPos.parentTextFrames[0];
var docPage;
try
{
docPage = docFrame.parentPage;
}
catch(e)
{
docPage = docFrame.parent.name;
}
alert(docPage.name);
}
Vandy
Copy link to clipboard
Copied
i try your new solution. i get the following error message.
I don't understand why ?
Copy link to clipboard
Copied
Hi kazegonzo,
Please try the below js code, I have access the doc/article/titre tag because the doc not placed into the pages, you placed the titre tags so i access the titre tag and get the page number.
var myDoc=app.activeDocument;
var root = myDoc.xmlElements[0];
var docTag = root.evaluateXPathExpression('//doc//article//titre');
for(i=0; i<docTag.length; i++){
var docPos = docTag.xmlContent.insertionPoints[0].parentTextFrames[0];
alert("Page: "+docPos.parentPage.name);
}
thx,
csm_phil
Message was edited by: csm_phil
Copy link to clipboard
Copied
hi csm_phil,
I understood my mistake. Thanks you and Vandy too. you are very helpful and patient to me.
I have just to put the return in a variable and it's done.
thx
kazegonzo
Copy link to clipboard
Copied
Hi kazegonzo,
Better you give some snapshots, your InDesign document xml structure and which tags you need to access and get the page number format.
thx,
csm_phil.
Copy link to clipboard
Copied
Hi csm_phil, pleased to see you.
what I trying to get is the page number for each tag "doc".
thanks for your help.
Kazegonzo
Find more inspiration, events, and resources on the new Adobe Community
Explore Now