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

Using the same form in more than one operating system

Engaged ,
Jul 04, 2023 Jul 04, 2023

Copy link to clipboard

Copied

I have a form that is used on both my Mac and Windows computers. It uses both document level and folder level scripts. The folder level scripts are identical on the two computers.

 

A menu item calls four folder level scripts that save different fdf files to 4 subfolders under the same parent folder.  On the Mac, all four scripts work as intended. On the PC, the first of the four scripts works but the other three seem to be completely ignored. No errors are thrown.

 

For purposes of my question, please assume the path to the subfolders is correctly structured. So here’s my question: are anomalies that are characterized by some scripts not quite working right somewhat common when using the same form on more than one operating system?

TOPICS
JavaScript , PDF forms

Views

2.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 , Jul 05, 2023 Jul 05, 2023

Security settings in Acrobat could easily block data export. This would be reported in the Console.  

Have you check your security preferences? Is Protected Mode turned on?  

 

Have you tried running the non-working scripts from the console window?

 

 

Votes

Translate

Translate
Community Expert ,
Jul 04, 2023 Jul 04, 2023

Copy link to clipboard

Copied

The same version of Adobe Acrobat?

Why does you use four folder level script files for one menu item?

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
Engaged ,
Jul 05, 2023 Jul 05, 2023

Copy link to clipboard

Copied

Because sometimes I call only one of them rather than all four.

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
LEGEND ,
Jul 05, 2023 Jul 05, 2023

Copy link to clipboard

Copied

It's rarely the operating system. Did you check the JavaScript console? (You say "no errors are thrown" but some people assume JavaScript errors will result in a pop-up message). 

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
Engaged ,
Jul 05, 2023 Jul 05, 2023

Copy link to clipboard

Copied

I wasn't suggesting that it was the operating system, but rather asking if it is known that when using the same form in Acrobat on different operating systems, there occasionally may be something that works just fine in one system but not the other. I prefaced that by saying for purposes of my question, please assume the path to the subfolders is correctly structured because I know that that is not the issue.

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 ,
Jul 05, 2023 Jul 05, 2023

Copy link to clipboard

Copied

The PDF form scripts work identically on both platforms. The problem certainly lies elsewhere.

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
Engaged ,
Jul 05, 2023 Jul 05, 2023

Copy link to clipboard

Copied

Yes, and that's why I asked my question. When the scripts work in Mac with no problem, they should work on on a PC also. 

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 ,
Jul 05, 2023 Jul 05, 2023

Copy link to clipboard

Copied

Security settings in Acrobat could easily block data export. This would be reported in the Console.  

Have you check your security preferences? Is Protected Mode turned on?  

 

Have you tried running the non-working scripts from the console window?

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 ,
Jul 05, 2023 Jul 05, 2023

Copy link to clipboard

Copied

Scripts in Acrobat are 99.9% platform-independent, meaning they should work just the same on both Windows and Mac computers. When the script doesn't work on Windows, is there an error message of some kind? Did you check the JS Console?

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
Engaged ,
Jul 06, 2023 Jul 06, 2023

Copy link to clipboard

Copied

Sorry for the slow response. Yes, the console is reporting this:

"GeneralError: Operation failed.
Doc.exportAsFDF:7:Field btn.Image.Folder:Mouse Up"

To repeat briefly, the only difference between the Mac version and the Windows version of my form are the paths with file names for the fdf files that saved by the scripts. Otherwise the scripts are exactly the same and work on the Mac but only partially on the PC.

The scripts construct absolute paths for each fdf file to be saved. The paths, file names and extensions are passed to the folder level scripts by parameters. I placed an app alert in each folder level script that shows me the path & file name represented by each "pathAndFile" parameter below, and confirmed that the path and filename for each is correctly constructed as "/C/Users/Dropbox/MyFolder/MyFile.fdf"

As to the console message, here are extracts of each instance of exportAsFDF from my folder level scripts, but I see nothing wrong with these:

this.exportAsFDF({bAllFields: true, cPath: "" + pathAndFile});
this.exportAsFDF({bAllFields: true, cPath: "" + pathAndFile});
this.exportAsFDF({bAllFields: true, aFields: ["txtProperty", "txt.Property"], cPath: "" + pathAndFile});
this.exportAsFDF({bAllFields: true, aFields: ["txtP","txtE", "txtSB", "chkTypeInd", "chkTypeCorp"], cPath: "" + pathAndFile});

And, once again, the scripts work with the mac but on the PC, just the first instance of exportAsFDF() in my scripts works, the rest do not.

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 ,
Jul 06, 2023 Jul 06, 2023

Copy link to clipboard

Copied

So what code is on line 7 of the script?  Is is the first "exportAsFDF"?   

 

I would suggest you do two things.

1)  Run the code on the system that doesn't work from the console window. Code run from the console has privilege, so we'll know a bit more if the code does or doesn't run.

 

2) Check the Acrobat Enhanced Security Preferences.  It's entirely possible that Acrobat on one of the computer is in Protected mode.

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 ,
Jul 06, 2023 Jul 06, 2023

Copy link to clipboard

Copied

Why are you exporting twice to the same file path in a row?

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
Engaged ,
Jul 06, 2023 Jul 06, 2023

Copy link to clipboard

Copied

I'm not. The pathAndFile parameters in my post are representative. In my script they are actually "toTransactions" and "toClientFolder" and passed to the function with this:

if(typeof fdfFilesTransaction === 'function') {
    fdfFilesTransaction(toTransactions, toClientFolder);
}
 
Here is the actual function that saves those two files:

var fdfFilesTransaction = app.trustedFunction(function(toTransactions, toClientFolder) {
app.beginPriv();
//Export to client folder, saved by file# + filename + fdf
this.exportAsFDF({bAllFields: true, cPath: "" + toClientFolder});

//Export to 'transaction' folder, save by property address + the file number + fdf
this.exportAsFDF({bAllFields: true, cPath: "" + toTransactions});

app.endPriv();
}
);

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 ,
Jul 06, 2023 Jul 06, 2023

Copy link to clipboard

Copied

Did you ever check the Acrobat Security Preferences?

 

And which specific line is throwing the exception?

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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
Engaged ,
Jul 06, 2023 Jul 06, 2023

Copy link to clipboard

Copied

Thanks for the suggestion.  I had the security preferences protected mode turned off.

 

The only console message I'm getting is this:

"GeneralError: Operation failed.
Doc.exportAsFDF:7:Field btn.Image.Folder:Mouse Up"

The thing that is so puzzling is that even on the Windows 11 PC the first exportAsFDF() in the script works as intended and the other four (which are constructed just like the first one) that follow the first one do not work (yet all of them work on the Mac). I'm trying to locate the source. I have a full time job that limits my ability to follow up posted suggestions quickly. Will keep at it.

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 ,
Jul 07, 2023 Jul 07, 2023

Copy link to clipboard

Copied

Couple of notes about this code:

1. You should pass a reference to the Doc object as a parameter, instead of using the "this" keyword, which might not always point to it in this context.

2. Add a command to print out the full path of the file name you're trying to save as to the Console. That might help locating issues with it. If you could post those paths here, that would be good too.

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
LEGEND ,
Jul 07, 2023 Jul 07, 2023

Copy link to clipboard

Copied

This sounds normal if Protected Mode is on. The specific purpose of Protected Mode is to stop files from being written by the Acrobat process. Switch it off. (Preferences > Security (Enhanced)), don't mix it up with Protected View.

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
Engaged ,
Jul 07, 2023 Jul 07, 2023

Copy link to clipboard

Copied

Thanks, but protected mode was already off. Also, the parent of all of the relevant sub folders was already added as a trusted folder in enhanced security. 

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
LEGEND ,
Jul 07, 2023 Jul 07, 2023

Copy link to clipboard

Copied

Please do share the path name from the one successful and four failing actions. 

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
LEGEND ,
Jul 07, 2023 Jul 07, 2023

Copy link to clipboard

Copied

(That is, the path name from your code, exactly as passed to the export ... call - not a telling of what you expect it to be. Probably best to write it to the console) 

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
Engaged ,
Jul 07, 2023 Jul 07, 2023

Copy link to clipboard

Copied

Here are the four fdf files being exported. The script camel-cases the file name. The images are in the order in which they are to be saved. 

1st.jpg

2nd.jpg

3rd.jpg

4th.jpg

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
Engaged ,
Jul 07, 2023 Jul 07, 2023

Copy link to clipboard

Copied

Replying further to try67's suggeston to use the Doc object instead of "this."

In the Mac if I change all four exportAsFDF() scripts from this.exportAsFDF() to doc.exportAsFDF(), the first in line of the export operations works, the remainder do not work. If I leave the first as doc.exportAsFDF() and the other three as this.exportAsFDF() they all work. If I leave them all as this.exportASFDF() they all work.

In the Windows 11 PC, if I change all four exportAsFDF() scripts from this.exportAsFDF() to doc.exportAsFDF(), none of them work. If I leave the first as doc.exportAsFDF() and the other three as this.exportAsFDF(), none of them work. If I leave them all as this.exportAsFDF() then the first in line works, the remainder do not 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 Expert ,
Jul 07, 2023 Jul 07, 2023

Copy link to clipboard

Copied

 Did you change the folder level function to include the doc object?  

If "this" and "doc" are the same the it makes not sense for them to work differently. 

Have you tried running each export separately?   It's possible that this function is non-blocking. Which means there could be a timing issue for two back to back calls. Perhaps separating the calls would fix the issue. 

 

var fdfFilesTransaction = app.trustedFunction(function(oDoc, toTransactions, toClientFolder) {
   app.beginPriv();
   //Export to client folder, saved by file# + filename + fdf
   oDoc.exportAsFDF({bAllFields: true, cPath: "" + toClientFolder});

   //Export to 'transaction' folder, save by property address + the file number + fdf
   oDoc.exportAsFDF({bAllFields: true, cPath: "" + toTransactions});

   app.endPriv();
});

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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
Engaged ,
Jul 07, 2023 Jul 07, 2023

Copy link to clipboard

Copied

Mystery solved. You previously asked if protected mode was enabled. I answered that it was not and that I had added the relevant folders are trusted folder paths. I would have lost money betting on my certainty that it protected mode was off. Checked again today and found it was ON. Turned it off and now all works as it should. It still seems odd that one of the scripts would work when protected mode is enabled, yet the others were blocked by protected mode. 

Thanks to everyone who helped with this. It's vey much appreciated.

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 ,
Jul 07, 2023 Jul 07, 2023

Copy link to clipboard

Copied

LATEST

It might stem from the folder to which you're saving the file. If you try to save it to a "protected" folder, like the root C folder, or the Windows folder, the Protected Mode could stop that. You didn't provide the actual paths you're saving the files to, though, so this is just a guess.

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