Our client uses Adobe Acrobat Pro DC at their office and they have a retention policy in place for the documents they keep on their systems in the office. I've written a script that sets the document info keyword field to the retention period that they've selected.
Upon saving the document the user is prompted to set the retention policy with a popup. However, this only works if the "Document Will Save" event is set. It's my understanding that the JS in "Document Will Save" is set on a per document basis. I can't expect my clients to set this action on every single document they open.
Is there a way that i can set this action on any document they open from their copy of Acrobat?
All suggestions are welcome!
Thank you so much!
The client can use a script for this.
Thank you for your quick response. This needs to be as transparent as possible to the client as they are not likely to be savvy with scripts, etc. I would like for them to be able to hit save and have it prompt them to set the retention policy if it hasn't already been, and that's it.
I've done all of the scripting work, I just can't figure out how to set the code in Document Will Save for each document, without the user having to do so.
Yes, I can call the setAction method, but what event do I hook into when each document first loads?
I need to be able to call setAction as soon as possible and I also need access to the document object.
I appreciate your patience with me.
This is not possible.
This is unfortunate, I've pored over the vast amounts of documentation you guys have, and I know you probably know this API back and forth.
In your professional opinion can you think of another approach that will accomplish the same general goal of prompting the user without requiring them to set a Document Action for every document they open?
I'm open to alternative solutions.
You can create a plug-in for Acrobat. The plug-in can add the script to any open document. The plug-in must be created with C/C++.
I was able to create the plug-in and register an App Notification for the AVDocDidOpen event. However I am not sure what method to use to populate the document's "Document Will Save" action. Is there anyway that you can point me in the right direction as I don't even really see any of Adobe's Sample Code doing that.
Is there a section dedicated to this topic in the Acrobat DC SDK Documentation?
You can add the action to the Page 1 open action.
What's the earliest point that I can call setPageAction? Can I call it as the document itself is opening?
So... If I were creating this project for you, I'd approach it very differently. I'd distribute a folder level script that removes the "Save" and "SaveAs" menu items and tool buttons and replace them with my own versions that do the check for the retention policy info, allows the user to set it if not there and then executes the save programmatically. That way you're not injecting code into the file that you really don't need.
Please let me know if this is not the case and if I am misusing the API.
Thanks for your suggestion!
One quick update: I was able to hide the menu items: Save/SaveAs.
However, when I call 'app.listToolbarButtons()' the returned array has a length of 0.
This method stopped working with Acrobat X, for no apparent reason, and never returned to work.
Thanks for confirming that!
Oh right. I forgot that removeToolButton() now only works with buttons that were added by your script.
I really appreciate your suggestion, though! Let me know if you have any other ideas.
As I mentioned to Mr. Alheit, I have a plugin working that fires an event on Doc Open, just trying to figure out how to inject my script into the "Document Will Save" action...
You probably want to register for the PDDocWillSave or PDDocWillSaveEx notification, then you can make your changes, if required.
Hope this helps
If I were designing this thing, I'd do it when the document opens rather than when it saves. That way you reinforce the fact that part of the creation process is setting the document retention policy is part of creating a document.
Essentially I just need to be able to read and write the Keyword from the Document MetaData and show a Dialog with buttons.
Can you point me to the best resource to read/write the keyword metadata safely from the PDDoc?
Here is what I have so far, but it's crashing...
Any help would be appreciated!
When posting code, post it as text, not as an image. That way someone could copy it over and test it for themselves. They're not going to do that if they need to type everything over...
In the future, questions about the Acrobat SDK should go here: Acrobat SDK
Thanks for the info try67!
I'm not a C++ guy but it looks like you are in good hands now.
I've been waiting for the question to appear in the SDK forum. There's a very obvious error, that it will crash if the metadata is more than 1000 characters. This might not have seemed likely, but think again!