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
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

try67
Community Expert
Community Expert
November 7, 2019

hahah yeah I didn't realize untill after I posted again! so we are wanting to do something very similar to what OP was wanting, the ability to add images to a pdf form. I used the code you posted above:

 

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;

    }

}

and the result was that I got a button like thing in a pdf, and it is able to be clicked on (looks like a button, acts like a button), but nothing actually happens. is there some tweak I need to make to the code somewhere that I'm not immediately noticing considering my complete beginner level in code of any kind?

 

One thing that's different I guess is that we don't really care that it automatically prompts the form-filler-outer to go to the next field. We just want maybe a half a dozen boxes that they can add an image to if they want. If it's one, ok; if they have six even better, but we don't need to automatically jump them to the next box.


You need to set the Mouse Up action of the button to execute this JavaScript code:

event.target.buttonImportIcon();