• 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

2.1K

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 21, 2018 Jun 21, 2018

Copy link to clipboard

Copied

Hi,

Is that the whole metadata? or just a specific section (Dublin core, XMP Core, etc.... ) ? and does it include tags? do you know, if so that is quite a limit.

Regards

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 Beginner ,
Jun 22, 2018 Jun 22, 2018

Copy link to clipboard

Copied

Yes! That did indeed end up being the issue. Thanks!

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 22, 2018 Jun 22, 2018

Copy link to clipboard

Copied

LATEST

To anyone in the future,

     I know this is the Javascript forum, but I really want to be thorough and not be that guy that says, "Thanks! It works now!" w/o showing a proper solution in the same thread that it started.

What Mr. Alheit suggested ended up being the best solution. Since the Javascript API doesn't allow registration of notifications on document-open. I ended up using the BasicPlugin C++ project from the Acrobat SDK, which I compiled under VS 2013 inside of a Windows 8.1 VM.

In PluginInit, I registered the AVDocDidOpenNSEL notification:

AVAppRegisterNotification(AVDocDidOpenNSEL, gExtensionID, (void*)myAVDocDidOpen, NULL);

Then I defined myAVDocDidOpen like this:

ACCB1 void ACCB2 myAVDocDidOpen(AVDoc doc, ASInt32 error, void* clientData) {

     PDDoc myPDDoc = AVDocGetPDDoc(doc);

     char ReturnValue[MAX_VALUE_LENGTH + 1] = "";

     char* pReturnValue = ReturnValue;

     char* js = "<folder-level js function call here>";

     AFExecuteThisScript(myPDDoc, js, &pReturnValue);

}

...and that did the trick!

I was concerned that the folder-level Javascripts wouldn't be loaded yet, but they are and everything is working great now!

Thank you to both Mr. Alheit and Mr. Geraci, who helped me think through this issue and come up with a working solution!

-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
LEGEND ,
Jun 21, 2018 Jun 21, 2018

Copy link to clipboard

Copied

There is no limit and your code is not adequate for the simplest real world file. You definitely should code defensively and expect any section could be megabytes, it happens. Then you won't be surprised.

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 21, 2018 Jun 21, 2018

Copy link to clipboard

Copied

HI,

Thanks that what I thought, and when dealing with metadata, coding defensively is always the call.

Regards

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