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

I want to specify the user's desktop in "cPath" specified in "saveAs" method..

Participant ,
Jul 12, 2020 Jul 12, 2020

I want to specify the user's desktop in "cPath" specified in "saveAs" method, but I don't know how to set the path.

 

What should I do with the location of "username" ?
Is it useless below?


Used in a multilingual environment.

this.saveAs("/c/Users/%userprofile%/" + aaa + ".pdf");

TOPICS
Acrobat SDK and JavaScript
952
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 ,
Jul 13, 2020 Jul 13, 2020

There's no direct way of doing it. What can be done, though, since you have to run your code from a trusted context anyway is to use the app.getPath method to access one of the other user folders, like the Documents ones, and from there get the Desktop path. It's a bit of a hack, but it does work, as long as keep in mind that it can vary per operating system.

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
Participant ,
Jul 13, 2020 Jul 13, 2020

very thank you for your advice. I've never used the app.getPath method, but I'll check it. The difference in operating system is the difference from Windows 10 or 7, right? Or is it Mac?

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
Participant ,
Jul 13, 2020 Jul 13, 2020

Create a text box in the field and put it there

var i = app.getPath("Documents");
event.value = i.value;

I wrote, but nothing is displayed. .. ..

Is something wrong?

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 ,
Jul 13, 2020 Jul 13, 2020

You have errors in your code, but also you can't use this method like that. Read up its documentation, especially the part related to the limitations of running it in a privileged context. Also see: https://acrobatusers.com/tutorials/trust-and-privilege-in-acrobat-scripts

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
Participant ,
Jul 13, 2020 Jul 13, 2020
LATEST

I understood. This sounds difficult to me, but I'll read it.
Thank you for your advice.

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