Cleaning up the look of this script ?
hello i've had ton of on here script. have done changes , wondering if possible clean below picture , script far. script bottom table on pic. top pic whats working right now. appreciated.
here's script.
function dotextframeonpageone() { // name of text frame save information in. var myblendingsettings = { blendmode : blendmode.overlay }; var mytransparencysettings = { blendingsettings : myblendingsettings }; var doc, tf, tvinfo, ip; doc = app.activedocument; // text frame properties tf = doc.pages[0].textframes.add({ fillcolor :"yellow", filltint: 20, transparencysettings : mytransparencysettings, geometricbounds: ['-.75','-4.45in','1.5in','-.75in'] }); // text frame information ip = tf.insertionpoints; ip[-1].contents = "document:"+"\t "+ doc.name +'\r'; ip[-1].contents = "user name:" +"\t"+ getappusername() +'\r'; ip[-1].contents = "computer name:" +"\t"+ getloginusername()+'\r'; tvinfo = ip[-1].textvariableinstances.add(locationoptions.after, ip[-1]); "date modified:" +'\t'; tvinfo.associatedtextvariable = doc.textvariables.itembyname("modification date"); ip[-1].contents = '\r'; tvinfo = ip[-1].textvariableinstances.add(locationoptions.after, ip[-1]); tvinfo.associatedtextvariable = doc.textvariables.itembyname("output date"); ip[-1].contents = '\r'; tvinfo = ip[-1].textvariableinstances.add(locationoptions.after, ip[-1]); tvinfo.associatedtextvariable = "date created:" +'\t'; doc.textvariables.itembyname("creation date"); // change properties of text frame.: }
thank you
chris bishop
this question creating table extendscript indesign.
basically have 2 options here:
[ ] convert text in text frame table
[ b ] create new table , assign contents via contents property of table
[ ] work you.
but can see first screen capture not work expected, if transforming current contents table, because missing necessary contents of column 1 rows. plus deviding tabulators. if provide that, use following code:
tf.parentstory.texts[0].converttotable("\t","\r");
[ b ] work result of functions , methods , necessary strings column 1 , 2 stored 1 or 2 arrays.
example:
var columnonecontentsarray = [ "document:" , "user name:", "output date:" ]; var columntwocontentsarray = [ "use test scripts.indd" , "chris bishop" , "" // not necessary use empty string, used indicate, cell empty now. ]; var doc = app.documents.add(); var tf = doc.textframes.add({geometricbounds : [0,0,"100mm","100mm"]}); var mytable = tf.texts[0].tables.add ( { bodyrowcount : 3 , // use larger number here, if contents array uses less entries. columncount : 2 // use other property/value pairs define width of table, stroke weights, fill color etc.pp. // ... } ); mytable.columns[0].contents = columnonecontentsarray; mytable.columns[1].contents = columntwocontentsarray;
in specific case leave out contents of text variables in columntwocontentsarray , substitute contents empty string "" perhaps.
later, after creating table, insert text variable in right cell using first insertion point of cell.
var cell3ofcolumn2insertionpoint1 = mytable.columns[1].cells[2].insertionpoints[0]; var tvinfo = cell3ofcolumn2insertionpoint1.textvariableinstances.add(locationoptions.after, cell3ofcolumn2insertionpoint1); tvinfo.associatedtextvariable = doc.textvariables.itembyname("output date");
warning: check before, if text variable already exists in document.
if yes, use existing one. if not, create new one.
note: did not test snippet text variable above.
btw.: thread should go indesign scripting forum.
uwe
More discussions in InDesign Scripting
adobe
Comments
Post a Comment