These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Delete all sounds

Paeon
Registered: Apr 12 2007
Posts: 30

Hello,
I have a 300 page file. Almost every page has one or more sound files attached. Acrobat does not provide a way to delete all sounds in the document. Instead, you are supposed to go to each page, select the sounds, then hit delete.

I found this in the AcroJS guide.

console.println("Dumping all sound objects in this document.");
var s = this.sounds;
for (var i = 0; i < this.sounds.length; i++)
console.println("Sound[" + i + "]=" + s[i].name);

This seems like this should do the trick. However, after evaluating in the Console, I get this error:

Dumping all sound objects in this document.
TypeError: this.sounds has no properties
3:Console:Exec
undefined

How might I use AJS to remove all the sound files?

Thanks.

My Product Information:
Acrobat Pro 9.0, Macintosh
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
How exactly did you attach the sounds you're asking about?

George
Paeon
Registered: Apr 12 2007
Posts: 30
The document is from a client. I suppose they used the sounds tool.

Thanks.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Maybe it is a "Sound" annotation tool.

Try this script in the JavaScript console:

// Get the comments in this document, and sort by author
this.syncAnnotScan();
annots = this.getAnnots({nSortBy: ANSB_Author});
// Open a new report
var rep = new Report();
rep.size = 1.2;
rep.color = color.blue;
if (annots) {
rep.writeText("Summary of Comments: By Author");
rep.color = color.black;
rep.writeText(" ");
rep.writeText("Number of Comments: " + annots.length);
rep.writeText(" ");
var msg = "\200 page %s: \"%s\" type of annotation: %s";
var theAuthor = annots[0].author;
rep.writeText(theAuthor);
rep.indent(20);
for (var i=0; i < annots.length; i++) {
if (theAuthor != annots[i].author) {
theAuthor = annots[i].author;
rep.writeText(" ");
rep.outdent(20);
rep.writeText(theAuthor);
rep.indent(20);
}
rep.writeText(
util.printf(msg, 1 + annots[i].page, annots[i].contents, annots[i].type));
}
} else {
var msg = "No annotations found in this document, %s.";
rep.writeText(util.printf(msg, this.documentFileName));
}
// Now open the report
var docRep = rep.open("myreport.pdf");
docRep.info.Title = "Sound Report";
docRep.info.Subject = "Summary of comments";

George Kaiser

George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
If they were created using the Sound tool, they would be screen annotations, and the doc.media section of the JavaScript reference would give the properties/methods available. Unfortunately, it doesn't look like you can delete them via JavaScript, unless I'm missing something...

You can get them deleted using PDF Optimizer, but it will remove all other annotations as well (in version 7 at least).

George
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
For the annotation object there is a "destroy()" method that can remove the annotation.

// get all the annotations
this.syncAnnotScan(); // update the annotation object
var annots = this.getAnnots(); // get the annotations
// delete all "Sound" type annotaions
for (var i = 0; i < annots.length; i++)
if (annots[i].type == "Sound") // see if it is sound
annots[i].destroy(); // delete sound

George Kaiser

Paeon
Registered: Apr 12 2007
Posts: 30
Sorry,
I need to read my email more often. Thanks for your ideas. I am not in possession of the document in question, but if I get it back, I will try out your ideas.

Thanks again.