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
});
}
}
Copy link to clipboard
Copied
To add a photo, use image field.
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,
});
Copy link to clipboard
Copied
Unfortunately, did not work for me 😞 keeps showing saying error message that file couldn't be uploaded
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!
Copy link to clipboard
Copied
" however, the button doesn't work when I'm trying to use it as a "guest"."
What do you mean by "use as guest"?