Copy link to clipboard
Copied
Hello,
I am creating a diagnostic tool for PDFs and the output from the diagnostic tool is a tab delimited file. I would like to use Javascript to add a flag for whether or not the document is read only. By read only, I mean any of the following:
1. If you go to the location of the PDF file, right click on the icon of the PDF file, click Properties, and then on the General tab in the Attributes section at the bottom, the Read-only checkbox is checked.
2. The file is open by another user
3. The file is locked
What has not worked is the solution offered in this post:
Determining if PDF is read only
appRightsValidate({nValidateOption: 1});
Any ideas are appreciated.
Thanks,
Chris
The "Read Only" you are describing is a file system property, not a PDF property. Try67 provided an indirect method for determining this, but it isn't exact. The only way to get direct info on this is from the OS. It cannot be done with JavaScript.
Copy link to clipboard
Copied
The only way I can think of is to edit the file in some way (or just set its dirty property as true) and then try to save it using the saveAs method. If it's set as read-only, or another user has it open, it will throw an exception which you could then catch and handle further.
Copy link to clipboard
Copied
The "Read Only" you are describing is a file system property, not a PDF property. Try67 provided an indirect method for determining this, but it isn't exact. The only way to get direct info on this is from the OS. It cannot be done with JavaScript.
Copy link to clipboard
Copied
Hi , I made my file Read-Only by changing its permissions and then edited it and tried saving it using saveAs as below
try {
var name = this.documentFileName;
var destPath = "/tmp/" + name;
this.saveAs({ cPath: destPath});
} catch(e) {
app.alert(e);
}
Without throwing any error file is getting saved
Copy link to clipboard
Copied
Read-only does not prevent the file from being saved elsewhere, only under the same name.
Try this code:
try {
this.saveAs({ cPath: this.path});
} catch(e) {
app.alert(e);
}
It should produce this error message: