Using Javascript to export a page level file attachment
Hello and thank you in advance for any light you can shine on this subject for me.
I'm creating a form in acrobat pro 10 that I want the users to be able to attach files to.
I don't know if the user will be filling out the form using Acrobat Pro or Reader so I'm using a logic statement in the document level Javascript to determine whether to use the "ImportDataObject" (Pro) or "AddAnot" (Reader) method.
The problem that I'm running into is that while I can export document level attachments using the "this.exportDataObject" function by referencing the name passed to the "ImportDataOjbect" function... I don't know how to export a page level file attachment added using the "AddAnot" function.
Really appreciate any help. I've written code in Visual Basic but Java Script is brand new to me, as is programming for Acrobat forms.
Document Level Java Script Added Below for Reference...
var oFAP = {x_init: -72, x: -72, y: -72}
function Attach(FileName) {
if (app.viewerType === "Reader")
try {
var annot = addAnnot({
page: event.target.page,
type: "FileAttachment",
author: FileName,
name: FileName,
point: [oFAP.x, oFAP.y],
contents: FileName,
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
});
}
else
{this.importDataObject(FileName)}
}
