JavaScript on how to be able to make a field link to an attachment

New Here ,
May 08, 2018 May 08, 2018

Copy link to clipboard

Copied

Hello Adobe friends,

I have now gotten help with my Javasripts I needed and they work.

I do have a small adjustment I need to have done with your help.

one of my boxes is a "OK" button and I run a Javascript on it so that my users can attach a file, and the file name is listed, I guess as a comment, in a text box I have namned "lst1". What I need is so that I can click on the listed name and it opens the attachment.

Meaning that the field that lists the name of the attachment, in my case "lst1", should always link to whatever attachment the user will attach. Is that even possible? Here is my JavaScript as it is now:

try {

  this.syncAnnotScan();

  var a = this.getAnnot(0, "Attachment1");

  if (a!=null) {

  a.destroy();

  }

  var annot = this.addAnnot({

        page: 0,

        type: "FileAttachment",

        point: [500, 500],

        noView: true,

        author: "Attachment",

  name: "Attachment1"

    });

    annot.cAttachmentPath;

    var attachmentObj = annot.attachment;

    if (attachmentObj !== null) {

        app.alert("Add this file: " + attachmentObj.name);

        var l = this.getField("lst1");

        l.value = attachmentObj.name;

    }

}

catch(e) {

    if (e.name == "NotAllowedError") {

        // do nothing

    }

}

Can you guys help a Swedish guy out?

TOPICS
Acrobat SDK and JavaScript

Views

87

Likes

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
no replies

Have something to add?

Join the conversation