• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Community Beginner ,
Aug 09, 2017 Aug 09, 2017

Copy link to clipboard

Copied

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

TOPICS
PDF forms

Views

8.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 09, 2017 Aug 09, 2017

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();

}

Votes

Translate

Translate
Community Expert ,
Aug 09, 2017 Aug 09, 2017

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 09, 2017 Aug 09, 2017

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 09, 2017 Aug 09, 2017

Copy link to clipboard

Copied

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();

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 10, 2017 Aug 10, 2017

Copy link to clipboard

Copied

Thanks, that works fine.

By the way, is there a way I can add or insert another Image Field with the same properties as I have used on the form using a script, if ever the user needs additional Image Field on the form.

Thanks again

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 10, 2017 Aug 10, 2017

Copy link to clipboard

Copied

You can do it in Acrobat, but not in Reader.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 10, 2017 Aug 10, 2017

Copy link to clipboard

Copied

i see. thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 10, 2017 Aug 10, 2017

Copy link to clipboard

Copied

hi again, added question:

I have 10 image fields and I used the script and it did work, however, if I only have 5 image to be added to the form, how can I stop the pop-up message from appearing continously even though I clicked the Cancel button on the Image Field?

Also, is there a way the script can detect if the Image Field is empty or not?

Thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 10, 2017 Aug 10, 2017

Copy link to clipboard

Copied

Yes, both things are possible. How do you want to use the latter, though?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 10, 2017 Aug 10, 2017

Copy link to clipboard

Copied

this is what I did, I created 10 Image Fields and each fields has the script on it.

for instance, one of the Image Field is empty, when I clicked on that Image Field, it will pop-up and ask me to insert Image for the 10 Image Field again.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 10, 2017 Aug 10, 2017

Copy link to clipboard

Copied

I don't follow how you want it to work, then...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 10, 2017 Aug 10, 2017

Copy link to clipboard

Copied

here is the page looks like, each of them has the script on it, since I used this script:

  1. for (var i=1; i<=10; i++) { 
  2.     app.alert("Select the image for field #"+i+":",3); 
  3.     this.getField("Image"+i).buttonImportIcon(); 
  4. }

If I added Image to each field, except the last one. Later I will add an image to the last Image Field, but the script will ask me again to add Image to the first Image Field, 2nd Image field and so on.

image.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 10, 2017 Aug 10, 2017

Copy link to clipboard

Copied

So you only want it to prompt you to select an image if the field doesn't already has one, or do you want it to only offer you to enter images from that field onwards (ie, if you click on field #8 it will prompt you for 8, 9 and 10)?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 10, 2017 Aug 10, 2017

Copy link to clipboard

Copied

can we do both?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 10, 2017 Aug 10, 2017

Copy link to clipboard

Copied

Yes, but that would make the code even more complex... Try this:

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

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

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

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

    try {

        util.iconStreamFromIcon(f.buttonGetIcon());

    } catch (e) {

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

    }

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 10, 2017 Aug 10, 2017

Copy link to clipboard

Copied

okay it did work, it skipped the Image Field that already has one, but a pop-up still appears for that particular Image Field. If I cancel adding Image to a particular field, the script stops already.

Also, if I wan't to update/edit/change the Image on that field, there's no option.

How about adding a Yes/Cancel button to the app.alert instead, if Cancel, it will add image to the next Image Field.

what is this for "util.iconStreamFromIcon(f.buttonGetIcon());"?

thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 10, 2017 Aug 10, 2017

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 10, 2017 Aug 10, 2017

Copy link to clipboard

Copied

Thanks. Already emailed you.

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

Cheers!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 07, 2019 Nov 07, 2019

Copy link to clipboard

Copied

Hi, we are wanting to do something very similar, but I am a complete novice in the code. I have tried to impliment this function, and I can get the box to look like it's clicking, but then nothing actually happens. I'm clearly missing something. is there some kind of tweak I need to make to get it to work? thanks, hopefully!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 07, 2019 Nov 07, 2019

Copy link to clipboard

Copied

oops, meant to trply to this comment. see question below, if you're still around dispersing knowledge!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 07, 2019 Nov 07, 2019

Copy link to clipboard

Copied

It's impossible to know what reply you replied to in these "wonderful" new forums... So what exactly are you trying to do, and what were the results?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 07, 2019 Nov 07, 2019

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 07, 2019 Nov 07, 2019

Copy link to clipboard

Copied

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

event.target.buttonImportIcon();

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 07, 2019 Nov 07, 2019

Copy link to clipboard

Copied

oh that's it?!

 

EDIT: same thing - it clicks, but nothing... obviously I'm missing something.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 07, 2019 Nov 07, 2019

Copy link to clipboard

Copied

Did you set the fields' Layout to "Icon Only" (under their Properties - Options)?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines