Skip to main content
Known Participant
August 9, 2017
Answered

how to insert multiple image in pdf form + drag and drop image to pdf form

  • August 9, 2017
  • 1 reply
  • 12167 views

is there a way I can create a pdf form that will enable user to insert multiple image at once in a pdf form? does Image Field has this option?

is drag and drop also allowed in a pdf form?

thanks

This topic has been closed for replies.
Correct answer try67

Let's say you have 10 button fields called "Image1", "Image2", etc., and you want to prompt the user to insert an image field into all of them, one after the other. You can use this code to do it (remove the alert window if you don't want it to appear before each file selection):

for (var i=1; i<=10; i++) {

    app.alert("Select the image for field #"+i+":",3);

    this.getField("Image"+i).buttonImportIcon();

}

1 reply

try67
Community Expert
August 9, 2017

You can use a script to prompt the user to insert images into multiple fields at once, but they will need to select the image for each field. If you want the images to be identical just give all the fields the same name.

Drag-and-drop is not possible, though.

iammundAuthor
Known Participant
August 9, 2017

My Client needs to be able to insert and select multiple photos, instead of inserting one photo at a time. let's say he needs to insert more than 10 image to the pdf form. it's not possible right? if yes, any suggestion though that I can also suggest to him.

thanks

iammundAuthor
Known Participant
August 10, 2017

Just move the alert into the catch clause, like this:

var fieldNumber = Number(event.target.name.replace("Image", ""));

for (var i=fieldNumber; i<=10; i++) {

    var f = this.getField("Image"+i);

    try {

        util.iconStreamFromIcon(f.buttonGetIcon());

    } catch (e) {

        app.alert("Select the image for field #"+i+":",3);

        if (f.buttonImportIcon()==1) break;

    }

}

If you want further customizations please contact me privately at try6767 at gmail.com.

That line of code identifies whether or not there's an icon already selected for that field by attempting to access it. When it fails we know there isn't an icon.


Thanks. Already emailed you.

Again appreciate all the help, will also try to play around the code.

Cheers!