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

JavaScript SaveAs with renaming filename

Community Beginner ,
Jan 27, 2024 Jan 27, 2024

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

TOPICS
JavaScript
7.1K
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
Community Expert ,
Feb 02, 2024 Feb 02, 2024

Try eliminating the issues I mentioned earlier.

There's no other way to save a file with JS.

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
Community Beginner ,
Feb 03, 2024 Feb 03, 2024

Hi try67,

on my network drive it doesn't work.

You see this path of my file.  But This.SaveAs with this path doesn't work. on my other directory without network drive it works. There must be something other on network drive.

Here you see my whole diretories. Which path do I have to use for saveas?

 

josuam70602286_0-1706996018274.png

 

 

josuam70602286_1-1706996018276.png

 

 

 

josuam70602286_2-1706996018279.jpeg

 

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
Community Expert ,
Feb 03, 2024 Feb 03, 2024

I gave you recommendations on what to try but you keep ignoring them. I can't help you further.

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
Community Beginner ,
Feb 04, 2024 Feb 04, 2024

I look to your recommendations, but this.path is only helpful for first directories where everything is working.

But now I have network path. There must be something different regarding path?

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
Community Expert ,
Feb 04, 2024 Feb 04, 2024

Read my replies again.

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
Community Beginner ,
Feb 04, 2024 Feb 04, 2024

I read several times your replies, but I don't read something regarding this network path problem?

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
Community Expert ,
Feb 05, 2024 Feb 05, 2024
quote

Could be the fact it's on a network drive, or the accented character in the folder name, for example.

Another option could be the "$" symbol in the path name.

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
Community Beginner ,
Feb 05, 2024 Feb 05, 2024

In my opinion the "$"  symbol in the path is the problem.  this.path works but

this.saveAs  doesn't work with "$".

Is there a workaround or solution for my $ problem?

 

josuam70602286_0-1707146751085.png

 

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
Community Expert ,
Feb 05, 2024 Feb 05, 2024

The only solution I can think of is to mount that folder as a drive, for example X:\. Then you could access it directly, like this "/X/<rest of path>".

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
Community Beginner ,
Feb 06, 2024 Feb 06, 2024

Is there a possibility for Escaping von $ in acrobat?  In other programming languages it is possible.  For instance in VBA you can write chr(36) for $ sign.

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
Community Expert ,
Feb 06, 2024 Feb 06, 2024

This is not really escaping a character, but writing it using its Unicode/ASCII character code, and yes, it is possible, but I don't believe it will solve this issue. You can do it like this:

String.fromCharCode(36)

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
Community Beginner ,
Feb 06, 2024 Feb 06, 2024

Ok, String.fromCharCode(36)  does not help.

Is there another mechanism for handling a $ character in the filename for the saveAs function? 

Create Trusted Function or anything else?

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
Community Expert ,
Feb 06, 2024 Feb 06, 2024

I don't think so.

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
Community Beginner ,
Feb 06, 2024 Feb 06, 2024

Ok, I have a solution. I write a powershell script and setting Y: to \\snas302\IDVen$\

Then I use Y in SaveAs and everything is working.  But it would be great if acrobat has a solution for SaveAs with $ sign.  Can we ask acrobat support?

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
Community Expert ,
Feb 06, 2024 Feb 06, 2024
LATEST

That's exactly what I recommended before...

And no, I don't think that Adobe Support will be able to help you with this. They don't deal with scripting issues.

You can post a feature request/bug report about this issue here, though: https://www.adobe.com/products/wishform.html

 

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