JS : 2 XML nodes in the same textFrame with 2 different style


hello,

 

i french , english poor. sorry in advance if unclear.

 

i have xml 2 nodes. fill texteframe these 2 nodes following , 2 different style. here current code:

 

var myrootxmlelement = mydocument.xmlelements.item(0).xmlelements.item(0).xmlelements.item(1).xmlelements.item(3 );

var myxmlelementa = myrootxmlelement.xmlelements.item(1); //node 1 (a firstname)

var myxmlelementb =  myrootxmlelement.xmlelements.item(2);//node 2 (a name)

 

 

myparagraphstyle = mydocument.paragraphstyles.item("al_qu_auteur"); // paragraphstyles

mycharacterstyle1 = mydocument.characterstyles.item("al_qu_prenom_auteur"); // characterstyles 1 firstname

mycharacterstyle2 = mydocument.characterstyles.item("al_qu_nom_auteur"); // characterstyles 1 for name

 

var mytextframe3 = mypage.textframes.add({geometricbounds:[156.5, 163, 170, 377.25]});

mytextframe3.placexml(myxmlelementa);

 

how add "myxmlelementa" in "mytextframe3"?

 

 

i try other code:

var myrootxmlelement = mydocument.xmlelements.item(0).xmlelements.item(0).xmlelements.item(1).xmlelements.item(3 );

var myxmlelementa = myrootxmlelement.xmlelements.item(1);

var myxmlelementb =  myrootxmlelement.xmlelements.item(2);

 

 

myparagraphstyle = mydocument.paragraphstyles.item("al_qu_auteur");

mycharacterstyle1 = mydocument.characterstyles.item("al_qu_prenom_auteur");

mycharacterstyle2 = mydocument.characterstyles.item("al_qu_nom_auteur");

 

 

var mytextframe3 = mypage.textframes.add({geometricbounds:[156.5, 163, 170, 377.25]});

mytextframe3.contents = myxmlelementa.contents + " " + myxmlelementb.contents ;

mytextframe3.parentstory.texts.item(0).applyparagraphstyle(myparagraphstyle, true);

 

but how add 2 characterstyle?

 

 

thank in advance

hi,

 

try this

 

var mypage = app.activedocument;

 

var rootelement = mypage.xmlelements.item(0);

 

var thetextframexml = rootelement.xmlelements.add("textframe");

var thetextframe = mypage.textframes.add({geometricbounds:[156.5, 163, 170, 377.25]});

 

thetextframe.placexml(thetextframexml);

 

var firstcharacterstyle = mypage.characterstyles.itembyname("al_qu_prenom_auteur");

thetextframexml.insertionpoints.item(-1).applycharacterstyle(firstcharacterstyle);

thetextframexml.insertionpoints.item(-1).contents = "first name";

 

space = thetextframexml.insertionpoints.item(-1).contents = " ";

 

var secondcharacterstyle = mypage.characterstyles.itembyname("al_qu_nom_auteur");

thetextframexml.insertionpoints.item(-1).applycharacterstyle(secondcharacterstyle);

thetextframexml.insertionpoints.item(-1).contents = "last name";

 

applying 2 character style 1 character (word etc.) not possible.

 

regards

 

b.



More discussions in InDesign Scripting


adobe

Comments

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

PProHeadless.exe has stopped working error when opening projects in Adobe Media Encoder CS6

Preconditions Failed. - Joomla! Forum - community, help and support