• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Same "Document Will Save" Action on every document?

Community Beginner ,
Jun 18, 2018 Jun 18, 2018

Copy link to clipboard

Copied

Hello Everyone,

      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!   

    Bob

TOPICS
Acrobat SDK and JavaScript , Windows

Views

1.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 18, 2018 Jun 18, 2018

Copy link to clipboard

Copied

The client can use a script for this.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 18, 2018 Jun 18, 2018

Copy link to clipboard

Copied

Mr. Alheit,

     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.

Thanks again!

     Bob

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 18, 2018 Jun 18, 2018

Copy link to clipboard

Copied

This is possible with the JavaScript method setAction.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 18, 2018 Jun 18, 2018

Copy link to clipboard

Copied

Mr. Alheit,

     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.

Thanks!

  Bob

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 18, 2018 Jun 18, 2018

Copy link to clipboard

Copied

This is not possible.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 18, 2018 Jun 18, 2018

Copy link to clipboard

Copied

Mr. Alheit,

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.

Thanks!

    Bob

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 18, 2018 Jun 18, 2018

Copy link to clipboard

Copied

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++.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 19, 2018 Jun 19, 2018

Copy link to clipboard

Copied

Mr. Alheit,

  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?

Thanks!

   Bob

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 18, 2018 Jun 18, 2018

Copy link to clipboard

Copied

You can add the action to the Page 1 open action.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 18, 2018 Jun 18, 2018

Copy link to clipboard

Copied

Mr. Geraci,

  What's the earliest point that I can call setPageAction? Can I call it as the document itself is opening?

I would like to set the javascript on the first load of the document if possible.

Thanks!

  Bob

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 18, 2018 Jun 18, 2018

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 19, 2018 Jun 19, 2018

Copy link to clipboard

Copied

Mr. Geraci,

    I like the sound of this, however it seems like disabling the Save and Save As menu items and tool buttons is forbidden using the Javascript APIs. I've even tried wrapping the hideToolbarButton calls with the beginPriv/endPriv functions.

Please let me know if this is not the case and if I am misusing the API.

Thanks for your suggestion!

     Bob

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 19, 2018 Jun 19, 2018

Copy link to clipboard

Copied

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.

Thoughts?

Thanks!

  Bob

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 19, 2018 Jun 19, 2018

Copy link to clipboard

Copied

This method stopped working with Acrobat X, for no apparent reason, and never returned to work.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 19, 2018 Jun 19, 2018

Copy link to clipboard

Copied

try67,

    Thanks for confirming that!

It seems that I will have to go with the plugin/javascript hybrid solution that Mr. Alheit mentioned.

Thanks!

  Bob

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 19, 2018 Jun 19, 2018

Copy link to clipboard

Copied

Oh right. I forgot that removeToolButton() now only works with buttons that were added by your script.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 19, 2018 Jun 19, 2018

Copy link to clipboard

Copied

Mr. Geraci,

   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...

Thanks again!

  Bob

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 19, 2018 Jun 19, 2018

Copy link to clipboard

Copied

HI,

You probably want to register for the PDDocWillSave or PDDocWillSaveEx notification, then you can make your changes, if required.

Hope this helps

Malcolm

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 19, 2018 Jun 19, 2018

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 19, 2018 Jun 19, 2018

Copy link to clipboard

Copied

Mr. Geraci,

     I think I will take the approach you are recommending. However, if I cannot set the "Document Will Save Action" scripts here then I will have to rewrite everything I did using Javascript API in C++.

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!

Thanks!

  Bob

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 19, 2018 Jun 19, 2018

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 20, 2018 Jun 20, 2018

Copy link to clipboard

Copied

Thanks for the info try67!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 20, 2018 Jun 20, 2018

Copy link to clipboard

Copied

I'm not a C++ guy but it looks like you are in good hands now.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 21, 2018 Jun 21, 2018

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines