Interactive PDF - 'Browse' or 'Add Attachment' Button
Copy link to clipboard
Copied
HI, I'm trying to work out how to add a button to an interactive PDF so students can attach photos. I've found a few examples which attach files to the PDF under "Attachments," but my problem is that students will be attaching multiple photos and when marking the document, I need a way for them to be identified. When they are showing under "Attachments," the name is just the file name. Can I either customise the name automatically when they are attached, or have the files linked to be opened n the same page they wee attached?
The javascript I have found which browses and attaches, but does not uniquely name or store files:
if (app.viewerVersion < 11) {
import_pre_11();
} else {
import_11();
}
Copy link to clipboard
Copied
What you found is very partial. You're missing the most important part of the code (the import_pre_11 and import_11 functions themselves)...
Are your users going to be using Adobe Acrobat (ie, not the free Reader) to fill in these files? If not, what you're asking for is not possible, unless a very special right is first applied to your file.
Copy link to clipboard
Copied
Yeah, I haven't done any extensive testing. Just providing a piece of script I'e found which was working for me upon very brief testing.
The users will be using Acrobat Reader
Copy link to clipboard
Copied
In that case it's a no-starter. The only way they can attach files (again, unless you apply this very special right to the file) is by using the Attach File commenting tool, and then you have no way of changing the file name of the attached files.
Copy link to clipboard
Copied
That code is from a demo file I provided: http://acroscript.net/pdf/demos/importFileJS_v1.pdf
It works with Reader 11 and later and prompts the user to select a file to be attached and doesn't require any usage rights. Although you are not able to change the file name, you can set the "name" and "contents" property of the file attachment. The name property doesn't show in the attachments panel, but the contents appears as the Description. You could use a script to display the attachments and include the name property though.

