parentPage is not working in CS4
Hi,
I am using the below script to clear paste board and getting the details what I cleared. But It is not working in CS4. It throw error in line 21, with parenPage is not supporting.
I tried instance of Spread but no use.
Original Thread: Re: Pasteboard items information
Could you please help to solve this?
var scriptName = "Delete objects on pasteboard",
doc;
PreCheck();
function Main() {
var obj, howManyImages,
objs = doc.pageItems.everyItem().getElements(),
countTotal = countTextFrame = countRectangle = countImage = 0;
var lnkname=[];
var layers=doc.layers;
for(var i=0;i<layers.length;i++){
if (layers.locked){
layers.locked=false;
}
}
var links = doc.links;
for(var j = 0; j < links.length; j++){
if(links
.parent.parent.parentPage == null){ lnkname.push(links
.name); }
}
for (var i = objs.length - 1; i >= 0; i--) {
obj = objs;
//lnkname.push(doc.allGraphics.itemLink.name);
//var doc = app.activeDocument;
if(obj.parentPage == null) {
if (obj.locked) {
obj.locked = false;
}
try {
howManyImages = obj.allGraphics.length;
obj.remove();
countTotal++;
countImage += howManyImages;
if (obj instanceof TextFrame) {
countTextFrame++;
}
if (obj instanceof Rectangle) {
countRectangle++;
}
}
catch(err) {
$.writeln(err.message + ", line: " + err.line);
}
}
}
var report = (countTotal == 0) ? "Nothing has been removed." :
"In total " + countTotal + " object" + ((countTotal == 1) ? " was" : "s were") + " removed.\nIncluding:\n\n" +
countTextFrame + " Text Frame" + ((countTextFrame == 1) ? "" : "s") + "\n" +
Number(countRectangle-countImage) + " Rectangle" + ((countRectangle == 1) ? "" : "s") + "\n" +
countImage + " Image" + ((countImage == 1) ? "" : "s" + "\nImage Name - \n"+lnkname.join("\n"));
alert(report, scriptName);
}
function PreCheck() {
if (app.documents.length == 0) ErrorExit("Please open a document and try again.", true);
doc = app.activeDocument;
if (doc.converted) ErrorExit("The current document has been modified by being converted from older version of InDesign. Please save the document and try again.", true);
if (!doc.saved) ErrorExit("The current document has not been saved since it was created. Please save the document and try again.", true);
Main();
}
function ErrorExit(error, icon) {
alert(error, scriptName, icon);
exit();
}
Regards,
K