Skip to main content
NogZoveelTeDoen
Inspiring
January 5, 2020
Answered

How to use the User's Documents folder in Javascript?

  • January 5, 2020
  • 2 replies
  • 1111 views

This works fine in the Javascript area of a pdf document:

this.exportAsXFDF({cPath:"/C/My folder/2020/File.XFDF",bAnnotations:true})

 But I don't know how to change the C/My folder/2020/File.XFDF to The User's Document folder/2020/File.XFDF?

This topic has been closed for replies.
Correct answer NogZoveelTeDoen

Today I worked on it and it and used a variable for the user documents map and filename. Then checked it with the app.alert function. And then put the variable after cPath and it workes fine. (Windows 8.1).

2 replies

try67
Community Expert
Community Expert
January 5, 2020

Yes, you can get it using this code, but you have to run it from a privileged context:

app.getPath("user", "documents");

NogZoveelTeDoen
Inspiring
January 7, 2020

Thank you for your reply, but I don't know where the privileged context is, only where the Javascript area of a pdf document is.

try67
Community Expert
Community Expert
January 7, 2020
Legend
January 5, 2020

The things available to you are deliberately limited and deliberately locked out of embedded JavaScript, but check out app.getPath, it looks like it is designed to return what you need.