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

How to add "add file attachment" button for pictures to fillable pdf? New Learner

Community Beginner ,
Jan 17, 2024 Jan 17, 2024

Copy link to clipboard

Copied

Hello- 

Trying to make registration forms for a program with online registration via fillable PDF on Acrobat Pro. I saw the original article on how to add a "file attachment" button but it keeps popping up as an error. I'm looking for the script (i have no idea how to use java) for people to be able to fill out the PDF and add a picture of themselves on the PDF as well. If there's a way to have it so it shows the actual picture instead of just in another uploaded files tab, I would greatly appreciate the help! This is what I have under script so far that another user answered: 

// Initialize attachment number

attachment_num = 1;

 

// Initial location of file attachment icon

// The x value is incremented below

var oFAP = {x_init: -72, x: -72, y: -72};  // Below lower-left corner of the page

 

function import_pre_11() {

 

    if (app.viewerType === "Reader") {

 

        app.alert({

            cMsg: "You must user Reader version 11 or later to attach files to this form.",

            cTitle: "Attach File Error",

            nIcon: 3,

            nType: 0

        });

   

        return;

    }

 

    // Prompt user to import a file

    app.alert({

        cMsg: "Click the OK/Open button after selecting the file from your system that you want to attach.",

        cTitle: "Attach File",

        nIcon: 3,

        nType: 0

    });

   

    try {

   

        var rc = this.importDataObject("Attachment" + attachment_num);

        if (rc) {

            attachment_num += 1;

            app.alert({

                cMsg: "Attachment successful.\r\rOpen the Attachments panel to access the attached file(s).",

                cTitle: "Attachment Successful",

                nIcon: 3,

                nType: 0

            });

           

        } else {

            app.alert({

                cMsg: "Attachment cancelled.",

                cTitle: "Attachment Cancelled",

                nIcon: 3,

                nType: 0

            });

        }

       

       

    } catch (e) {

        app.alert({

            cMsg: "Could not attach file.",

            cTitle: "Could not attach file",

            nIcon: 3,

            nType: 0

        });

    }

 

}

 

function import_11() {

 

    try {

 

        var annot = addAnnot({

            page: event.target.page,

            type: "FileAttachment",

            author: "Form user",

            name: "File Attachment",

            point: [oFAP.x, oFAP.y],

            contents: "File attachment on: " + util.printd("yyyy/mm/dd HH:MM:ss", new Date()),

            attachIcon: "Paperclip"

        });

 

        annot.cAttachmentPath; // Prompt user to select a file to attach

       

        oFAP.x += 18;  // Increment the x location for the icon

       

       

    } catch (e) {

 

        app.alert({

            cMsg: "Could not attach file.\r\rPlease report this error.",

            cTitle: "File attachment error",

            nIcon: 3,

            nType: 0

        });

 

    }

   

}

TOPICS
Edit and convert PDFs , How to , JavaScript , PDF , PDF forms

Views

117

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 17, 2024 Jan 17, 2024

Copy link to clipboard

Copied

To add a photo, use image field.

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 17, 2024 Jan 17, 2024

Copy link to clipboard

Copied

This script is old and unnecessarily complicated, try this one:

 

var annot = this.addAnnot({
page: this.pageNum,
type: "FileAttachment",
author: "Me",
contents: "Double-click to open the attachment",
attachIcon: "PushPin",
point: [500,500],
strokeColor: color.red,
});

 

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 18, 2024 Jan 18, 2024

Copy link to clipboard

Copied

Unfortunately, did not work for me 😞 keeps showing saying error message that file couldn't be uploaded 

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 18, 2024 Jan 18, 2024

Copy link to clipboard

Copied

Thank you!! Update: I was able to do it and the pin popped up, however, the button doesn't work when I'm trying to use it as a "guest". I'm trying to get it so people will to be able to upload their headshots onto the registration PDF for paperless online registration.  thank you again! 

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 19, 2024 Jan 19, 2024

Copy link to clipboard

Copied

LATEST

" however, the button doesn't work when I'm trying to use it as a "guest"."

What do you mean by "use as guest"?

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