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

How to resolve Warning JavaScript Window Invalid File Location Error

Community Beginner ,
Jan 08, 2018 Jan 08, 2018

Copy link to clipboard

Copied

Apologies in advance as I have little JavaScript experience. A JavaScript was created by another coworker who also has little JavaScript experience and propagated to a specific file server folder/share location on our domain network. The script forces users to open PDF documents from this specific location and so prevents users from creating copies of what would be otherwise outdated documents (As was previously the issue). This script also auto time-stamps and closes the document after being printed. All of these JavaScript PDF's are accessed by our domain users via a Microsoft Access database (hyperlinks). These hyperlinks link directly to the file server folders where these JavaScript PDF's are located. This has worked without issue for some time but something has changed. The issue is that something has occurred that now prevents the PDF's with this JavaScript from opening. An error now appears (Warning: JavaScript Window - Invalid File Location). I can see the portion of code causing the prompt and the PDF will open if this portion is removed, however, they want the functionality of it to work as intended. It appears that windows accounts on any domain user computer that were created before this issue surfaced can still open these JavaScript PDF files, however, all newly created Windows accounts on any domain computer for both existing and new users experience the error/issue.  I have pasted the script being used below. I have emboldened the error. I am hoping someone has an idea as to what may be happening.

//-------------------------------------------------------------

//-----------------Do not edit the XML tags--------------------

//-------------------------------------------------------------

//<Document-Level>

//<ACRO_source>load</ACRO_source>

//<ACRO_script>

/*********** belongs to: Document-Level:load ***********/

var allowedPath = "/SERVER/DIRECTORY/FOLDER/";

if (this.path.indexOf(allowedPath)!=0) {

    app.alert("Invalid file location!");

    this.closeDoc(true);

}

//</ACRO_script>

//</Document-Level>

//<Document-Actions>

//<ACRO_source>Document Will Print</ACRO_source>

//<ACRO_script>

/*********** belongs to: Document-Actions:Document Will Print ***********/

    var f = this.getField("DatePrinted");

    f.hidden = false;

    f.value = "Printed on: " + util.printd("HH:MM dddd, dd mmmm, yyyy", new Date());

    this.dirty = false;

    this.closeDoc(true);

//</ACRO_script>

//</Document-Actions>

TOPICS
Acrobat SDK and JavaScript , Windows

Views

6.0K

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Jan 08, 2018 Jan 08, 2018

Maybe they are opening the file from a local folder, instead of the network folder?

Also, keep in mind that JS is case-sensitive, so if the network folder is mapped with lower-case letters instead of upper-case ones (as it appears in the code), it's not going to work.

Votes

Translate

Translate
Community Expert ,
Jan 08, 2018 Jan 08, 2018

Copy link to clipboard

Copied

You will get the message when /SERVER/DIRECTORY/FOLDER/ is not part of the file paths.

Votes

Translate

Translate

Report

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 ,
Jan 08, 2018 Jan 08, 2018

Copy link to clipboard

Copied

Has the path to the document changed? One thing you could do is show what the path is before closing the document. You can do that by either printing to the console, or by adding the path to your message dialog.

Here is a combination of both solutions:

var allowedPath = "/SERVER/DIRECTORY/FOLDER/";

if (this.path.indexOf(allowedPath)!=0) {

     console.println("Path is " + this.path);

    app.alert("Invalid file location!\nPath = " + this.path);

    this.closeDoc(true);

}

This way you can see why the scripts assumes that the location is not valid.

Votes

Translate

Translate

Report

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 ,
Jan 08, 2018 Jan 08, 2018

Copy link to clipboard

Copied

I will try this out. The path has not changed and still works for any user on a windows domain account that had setup the account prior to this issue surfacing. When exactly it surfaced I do not know. Thank you.

Votes

Translate

Translate

Report

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 ,
Jan 08, 2018 Jan 08, 2018

Copy link to clipboard

Copied

When you open a PDF file you can see the location at File > Properties > Description

Votes

Translate

Translate

Report

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 ,
Jan 08, 2018 Jan 08, 2018

Copy link to clipboard

Copied

For those users where the script is working, they can open the file and see the file path as you say (\\SERVER\DIRECTORY\FOLDER\SUB-FOLDER). For those who experience the error, file is greyed out and acknowledging the error closes the partially visible (top menu items) pdf. Both are using the same script.This script is working for some and not for others.

Votes

Translate

Translate

Report

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 ,
Jan 08, 2018 Jan 08, 2018

Copy link to clipboard

Copied

In the preferences of Acrobat Reader disable JavaScript and open the file.

Votes

Translate

Translate

Report

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 ,
Jan 08, 2018 Jan 08, 2018

Copy link to clipboard

Copied

Files open without issue with JavaScript disabled.

Votes

Translate

Translate

Report

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 ,
Jan 08, 2018 Jan 08, 2018

Copy link to clipboard

Copied

This did add an entry to the error below "Invalid File Path!"

Adds the entry  "Path = /server/directory/folder/sub-folder/file.pdf"

The script covers, or should cover, any Sub-folder under the parent folder directory. The script is working for some users and not for others.

Votes

Translate

Translate

Report

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 ,
Jan 08, 2018 Jan 08, 2018

Copy link to clipboard

Copied

Maybe they are opening the file from a local folder, instead of the network folder?

Also, keep in mind that JS is case-sensitive, so if the network folder is mapped with lower-case letters instead of upper-case ones (as it appears in the code), it's not going to work.

Votes

Translate

Translate

Report

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 ,
Jan 08, 2018 Jan 08, 2018

Copy link to clipboard

Copied

I think you may be right that case sensitivity is the issue. File paths are using caps on some systems and not on others. I will reply back soon. Thank you.

Votes

Translate

Translate

Report

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 ,
Jan 08, 2018 Jan 08, 2018

Copy link to clipboard

Copied

LATEST

To fix it in the code above change this line:

if (this.path.indexOf(allowedPath)!=0) {

To:

if (this.path.toUpperCase().indexOf(allowedPath)!=0) {

Votes

Translate

Translate

Report

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 ,
Jan 08, 2018 Jan 08, 2018

Copy link to clipboard

Copied

Case sensitivity is the issue. This is what we get for dabbling in dark arts we do not understand. Big thanks to you and everyone else for the help.

Votes

Translate

Translate

Report

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