Skip to main content
Known Participant
January 27, 2024
Question

JavaScript SaveAs with renaming filename

  • January 27, 2024
  • 1 reply
  • 10288 views

Dear Community,

I'm new with JS and Acrobat. I'm looking for a small Code for following Task:

I have an open pdf file and now I need a button to do the following:

Only save the open file in the same directory, but with filename = oldfilename_username.pdf  so I can

work with this new file. The old file should be closed. I think I  need identity.loginname  for username.

Is the best was use an Action with JavaScript Code?

 

Do you have some Code for me?

 

Best Regards

Josh

This topic has been closed for replies.

1 reply

Known Participant
January 27, 2024

This code does not work:

 

 

Nesa Nurani
Community Expert
Community Expert
January 28, 2024

Run the script from trusted function.

identity.loginName = The login name as registered by the operating system.

identity.name = The user name that the user entered in the Identity preferences panel.

Known Participant
February 2, 2024

If I run your command in console window with file open,  it doesn't work on directory.

It's a network drive

 

 

 

But if I run on other directory it works (I see undefined, but I see the correct file with new filename), great.

Is there a possibiltiy to run script on network drive, too?

 

 


Hi try67, hi Bernd, hi Nesa,

 

the js file works on this directory. It is great. I put it in action with MyDocSave(this); and it works.

Now we know the problem.

But on this network drive it doesn't work. What can I do to get same result?

Perhaps I have to use a little bit other code then    path.saveas ?