7 Replies Latest reply on Nov 24, 2010 5:37 AM by ChristianPam

    PDF Attachments (using FDF?)

    ChristianPam

      Hello there,

       

      i've already tried a lot but it didn't work.

      I have a PDF and a FDF. I want to attach a file to pdf, when the user opens the pdf via hyperlink for example

      "http://www.pdfgeneratortest.de/foo.pdf#FDF=http://www.pdfgeneratortest.de/generateFDF.php".

      The fdf is already filling the pdf formfields. The next step is to attach a specific file storaged on a server to the pdf...

      But it won't work...

      For example i've already tried to add a file by a static path.

      oAttachNewFile = app.trustedFunction (
           function(cName, doc) {
                app.beginPriv();
                     var bRtn = event.target.importDataObject(cName);
                     if(bRtn) {
                          app.alert("file Attachment Succesfully Imported", 3);
                     } else {
                          app.alert("Unable to import File Attachment", 0);
                     }
                 app.endPriv();
           }
      );

      try{
                oAttachNewFile("testfile", "c:/testpath/file.pdf");
           } catch(e) {
                app.alert("An error Occured while Importing the File Attachment:\n\n" + e);
           }

      But it won't work?!... nothing happens instead of following

      "NotAllowedError: Security settings prevent access to this property or method.
      App.trustedFunction:15:Page undefined:Open"

       

      How to solve this problem?

        • 1. Re: PDF Attachments (using FDF?)
          try67 MVP & Adobe Community Professional

          Is this script located in a Page Open action? If so, then it won't work, as

          this is not a safe context.

          You need to place it in a folder-level script, and pass the document

          reference to it.

          • 2. Re: PDF Attachments (using FDF?)
            ChristianPam Level 1

            I've tried to do it with a folder-level script. But it didn't work.

            So I've tried to find out, where the folder is to hold folder-level scripts. But the security settings prevent me to do this.

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

            app.getPath("app","javascript");

             

            I'm sorry for my (probably) easy questions, but i can't find a way to solve it :-(

             

            I just only want to add an attachment, which depends on a specific path, to the adobe acrobat - created pdf by using a textfield in the pdf, having the filepath, and a javascript that attachs the file to the pdf as an attachment? :-(

            • 3. Re: PDF Attachments (using FDF?)
              George_Johnson MVP & Adobe Community Professional

              If you run that code in the interactive JavaScript console, it will work.

               

              More info: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_Dev_Tools.72.4.html

              • 4. Re: PDF Attachments (using FDF?)
                ChristianPam Level 1

                .... I've get to know that normal attachments can't be added to a pdf, when the client uses an adobe reader.

                 

                So I'm trying to do this: Add a file as a comment to the pdf.

                But the adobe-reader-feature-extended pdf can't even attach files as comments. I'm confused about it, because the user is able to sign the document digital but not to attach files as comments?

                Adobe Reader sends the messagebox: "no comments have been imported" - it seems like "an error occured" , but what else? errorcode? reason why? ...

                • 5. Re: PDF Attachments (using FDF?)
                  ChristianPam Level 1

                  Hello after trying out a lot of things, i've got a painful headache and no idea how to solve the problem.

                  Now i've placed a button on the pdf and an invisible textfield... i'm trying to add a hyperlink to the button, so that the hyperlink opens when the button is clicked?

                  so that's what i've done:

                  var txtfld = this.getField("URL");

                  var btn = this.getField("Button2");
                  btn.setAction("MouseDown","this.getURL(txtfld.value)");

                   

                  And what happens?

                  instead of an errormessage nothing:

                   

                  NotAllowedError: Security settings prevent access to this property or method.
                  Doc.getURL:1:Field Button2:Mouse Down

                   

                  I've written this code in the page open event (adobe acrobat).

                   

                  Please help me :-(

                  • 6. Re: PDF Attachments (using FDF?)
                    try67 MVP & Adobe Community Professional

                    Problem #1: The script that you assign to the button has a different scope

                    than the script that you are running, so it has no knowledge of the txtfld

                    variable you defined. You need to move the line of code that defines it into

                    the MouseDown code.

                    Problem #2: The reference file states the following about getURL:

                    "NOTE:(Security S): Beginning with Acrobat 6.0, if bAppend is true, the

                    getURL method can only be executed during a console, menu or batch event."

                    Since you don't specify the bAppend value, it gets the default value of

                    "true", which means you can't call this method from a button action.

                    • 7. Re: PDF Attachments (using FDF?)
                      ChristianPam Level 1

                      ok even if i add the code into the mouse-enter event or mouse-down event, nothing will happen right?

                      so how to solve the problem or this issue?

                      I can't manipulate the bAppend to false, right?


                      I mean there should be a workaround/hack to solve this issue.

                       

                      The only thing i want to do is to add an attachment or hyperlinkbutton to the pdf , that depends on the fdf that delivers a path of an document?

                      i hope you can understand me?

                      The user, who uses adobe reader, should have access to the document or file, that is defined in the fdf.

                      The best way is to attach this file to the pdf (most comfortable for user) but another possibility is to open a hyperlink that refers the file or document...

                      Please tell me how to do it.I'm in despaired :-(