Skip to main content
hurix
Inspiring
October 30, 2012
Question

Using Library Items

  • October 30, 2012
  • 1 reply
  • 1271 views

Hi,

Can anybody help me on the following  scripts.

I have a Indesign library which contain Box Frame. This a text frames.

What I want is, pull the element from the library and place some text in the textframe and place that element in the indesign  pages either top or bottom.

I am able to  pull the element from the library. But unable to place the text into the textframes and place top or bottom.

Can anybody help me on this.

My coding is below.

-------------------------

var graphicLibrary = new File("/Users/Hurix/Desktop/Books/Library.indl");
if (graphicLibrary.exists) {
    app.open(File("/Users/Hurix/Desktop/Books/Library.indl") );   
    }
else {   
    alert("Creating new Library");
    var graphicLibrary = app.libraries.add(File("/Users/Hurix/Desktop/Books/Library.indl"));
    }

var getGraphics = getGraphicsFunc(graphicLibrary);

function getGraphicsFunc(graphicLibrary)
{
    var t = app.libraries.item(0);
    libList = t.assets.everyItem().name;
    for (var i=0; i<libList.length; i++)
    {
        myAsset = t.assets.item(i);
        var libItem = myAsset.placeAsset(app.documents[0]);
        }
    }

My XML Code:

<sidebar>

<p>XXX</p>

<p>xxx</p>

</sidebar>

Ram

Message was edited by: hurix@123

This topic has been closed for replies.

1 reply

Jump_Over
Legend
October 30, 2012

Hi,

var libItem = myAsset.placeAsset(app.documents[0]);

At this point script is placing each myAsset on doc 1st page.

To move it use libItem.move() method.

libItem.move([x,y]) means move TO x,y coordinates;

libItem.move(undefined, [x,y]) means move BY x,y coordinates;

to fill myAsset with text use libItem.contents = "bla bla";

or libItem.place(MyContents) method.

if your MyContents = File( "/Users/Hurix/Desktop/Books/Content.txt").

rgds

hurix
hurixAuthor
Inspiring
October 30, 2012

My XML code is:

<sidebar>

<p>XXX</p>

<p>XXX</p>

</sidebar>

i want place above element into that box frame.

Ram

csm_phil
Legend
October 30, 2012

Hi Hurix,

You already request the same in the below mentioned thread. Why you not try, Don't expect everything in the forum.

http://forums.adobe.com/thread/576971?tstart=0

Note: Please apply correct answer if any one given the code. Please do the correct answer or help answer. Still you have lot of unanswered thread in your profile.

thx,

csm_phil.