PageItem showing as valid when checked with JS but it actually does not exists in the document.


hello all,

 

there pageitem id "1784" when checked of js

 

var thedoc = app.documents.item(0);

var thepitem = thedoc.pageitems.itembyid(1784);

$.writeln(thepitem.isvalid);

 

comes out valid in real pageitem not exists in document..

 

there when checking properties parent of pageitem script crashes...


can me out how can check validity of pageitem in case , how can pageitem turn out valid if not exists in document...

 

link includes document file ...

https://www.dropbox.com/s/do2449rgdlc61qa/testdata.indd?dl=0

 

any appreciated ..

 

thanks in advance

bhumika

hi bhumika,

iterate through allpageitems array of document , ids.

a pageitem id 1784 not there.

 

it misconception think available ids pageitem class denote object on page.

what return pageitem resolved? :

 

app.documents[0].pageitems.itembyid(1).getelements()[0]; // returns: [object document] 

 

what return in case?

 

app.documents[0].pageitems.itembyid(1784).getelements()[0]; // returns: [object pageitem] 

 

i ran following script on document german estk:

 

var doc = app.documents[0];  for(var n=1;n<2000;n++) {     try{     $.writeln(n+"\t"+doc.pageitems.itembyid(n).getelements()[0]);     }catch(e){n+"\t"+e.message}; } 

 

here results.

note, ids missing without being caught error handler:

 

1    [object document] 7    [object ink] 8    [object ink] 9    [object ink] 10    [object ink] 11    [object color] 12    [object color] 13    [object color] 14    [object swatch] 15    [object color] 16    [object color] 17    [object color] 55    [object numberinglist] 57    [object language] 78    [object language] 79    [object language] 110    [object characterstyle] 111    [object paragraphstyle] 114    [object paragraphstyle] 117    [object cellstyle] 119    [object tablestyle] 121    [object tablestyle] 124    [object color] 125    [object gradient] 126    [object color] 127    [object namedgrid] 128    [object objectstyle] 130    [object objectstyle] 131    [object objectstyle] 132    [object objectstyle] 134    [object tocstyle] 135    [object compositefont] 136    [object compositefontentry] 138    [object compositefontentry] 139    [object compositefontentry] 140    [object compositefontentry] 141    [object compositefontentry] 143    [object compositefontentry] 144    [object xmlstory] 169    [object layer] 170    [object trappreset] 171    [object trappreset] 172    [object section] 175    [object xmltag] 177    [object masterspread] 182    [object page] 191    [object assignment] 194    [object color] 195    [object color] 196    [object color] 197    [object color] 198    [object color] 199    [object ink] 200    [object color] 201    [object color] 202    [object color] 203    [object color] 204    [object color] 205    [object color] 206    [object color] 207    [object color] 209    [object gradient] 210    [object gradient] 211    [object gradient] 212    [object gradient] 218    [object characterstyle] 219    [object paragraphstyle] 220    [object paragraphstyle] 221    [object paragraphstyle] 257    [object layer] 262    [object spread] 275    [object page] 280    [object guide] 281    [object guide] 282    [object guide] 283    [object guide] 284    [object guide] 285    [object guide] 286    [object guide] 287    [object guide] 288    [object guide] 289    [object guide] 1027    [object group] 1028    [object graphicline] 1029    [object graphicline] 1030    [object graphicline] 1031    [object graphicline] 1032    [object graphicline] 1034    [object story] 1052    [object textframe] 1055    [object graphicline] 1056    [object graphicline] 1057    [object graphicline] 1058    [object graphicline] 1059    [object graphicline] 1061    [object story] 1079    [object textframe] 1082    [object graphicline] 1083    [object graphicline] 1084    [object graphicline] 1086    [object story] 1104    [object textframe] 1107    [object graphicline] 1108    [object graphicline] 1109    [object graphicline] 1111    [object story] 1129    [object textframe] 1132    [object graphicline] 1134    [object story] 1152    [object textframe] 1668    [object crossreferenceformat] 1669    [object crossreferenceformat] 1670    [object crossreferenceformat] 1671    [object crossreferenceformat] 1672    [object crossreferenceformat] 1673    [object crossreferenceformat] 1674    [object crossreferenceformat] 1675    [object crossreferenceformat] 1676    [object crossreferenceformat] 1780    [object pageitem] 1781    [object pageitem] 1782    [object pageitem] 1783    [object pageitem] 1784    [object pageitem] 1826    [object color] 1827    [object color] 1836    [object xmltag] 1837    [object xmltag] 1841    [object xmltag] 1999    objekt ist ungültig 

 

"objekt ist ungültig" => "object not valid" ( message error handler )

 

so pageitem id 1784 existing, not item think is.

and yes, reading out properties crash indesign.

 

uwe

 

btw.: thread should moved indesign scripting



More discussions in InDesign Scripting


adobe

Comments

Popular posts from this blog

Error during signature verification. Signature contains incorrect, unrecognized, corrupted or suspicious data. Support Information: SigDict /Contents illegal data