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

How to add the current date and time to the filename when saving the file in Adobe Pro XI?

Explorer ,
Feb 29, 2016 Feb 29, 2016

I would like to get the date and time to append to the filename of a pdf file when it is saved.

Here is the function used for saving the file when a button is clicked:

mySaveAs = app.trustPropagatorFunction(function(doc,path)

{

app.beginPriv();

doc.saveAs(path);

app.endPriv();

})

myTrustedSpecialTaskFunc = app.trustedFunction(function(doc,path)

{

// Privileged and/or non-privileged code above

app.beginPriv();

mySaveAs(doc,path);

app.endPriv();

// Privileged and/or non-privileged code below

});

Here is the code for the button (mouseup):

myTrustedSpecialTaskFunc(this, "/F/signedcontracts/signeddoc.pdf");

I would like to have the filename in the following format:

/F/signedcontracts/signeddocyyyymmddhhmmss.pdf

I have read through and tried several examples, but I'm still unable to get it to work properly.

TOPICS
Acrobat SDK and JavaScript , Windows
533
Translate
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
Explorer ,
Mar 01, 2016 Mar 01, 2016
LATEST

I got it to work:

Function:

function myDateSTring(){

return util.printd("yyyymmdd_HHMMss", new Date());

}

mySaveAs = app.trustPropagatorFunction(function(doc,path)

{

app.beginPriv();

doc.saveAs(path);

app.endPriv();

})

myTrustedSpecialTaskFunc = app.trustedFunction(function(doc,path)

{

// Privileged and/or non-privileged code above

app.beginPriv();

mySaveAs(doc,path);

app.endPriv();

// Privileged and/or non-privileged code below

});

Button script:

myTrustedSpecialTaskFunc(this, "/F/signedcontracts/signed-doc-jlf"+myDateSTring()+".pdf");

Translate
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