/ Id-Extras Forum / Document Action Close script?
April 29, 2021 at 3:38 pm #6180
So the answer is to add your document “Will Close” action by creating a document script that adds it.
Once you’re ready to distribute the PDF, simply delete that particular document script from the PDF.
To add a document action script is really simple. Here’s an example of adding a “WillSave” and “DidSave” action (from the Acrobat SDK):Code:// WillSave script
var myWillSave = ‘var filesizeBeforeSave = this.filesize;r’
+ ‘console.println(“File size before saving is ” + ‘
+ ‘ filesizeBeforeSave );’;
// DidSave script
var myDidSave = ‘var filesizeAfterSave = this.filesize;r’
+ ‘console.println(“File size after saving is “‘
+ ‘var difference = filesizeAfterSave – filesizeBeforeSave;r’
+ ‘console.println(“The difference is ” + difference );r’
+ ‘if ( difference < 0 )rt' + 'console.println("Reduced filesize!");r' + 'elsert' + 'console.println("Increased filesize!");' // Set document actions... this.setAction("WillSave", myWillSave); this.setAction("DidSave", myDidSave);
… and for for “WillClose” you’d do exactly the same.
Does that make sense?