Adding image to PDF form

  • vikramsonawane
    Asked on January 25, 2017 at 3:31 AM

    Hi,

     

    I have created a form using JotForm and I'm filling up the form programmatically (using iText). I'm able to fill text field values without any issue. Problem is I'm not able to see the image field when I scan through the form I created using JotForm; Once I'm able to get an handle to the image field, I'll be able to populate the image.

    Any help on this would be much appreciated.

    Thanks,

    VS

  • Support_Management Jotform Support
    Replied on January 25, 2017 at 4:13 AM

    Hello VS, we can better understand how to help if you could share more information on what you're doing (and how you're doing it) via iText.

    IINM, you're using iText to programmatically fill out the form, and you mentioned it works great, except for the image field.

    Can you give us a bit of background on how you're doing it? Are you using our APIs? Also, which iText are you using specifically - This one http://itextpdf.com/ or this one https://sourceforge.net/projects/itext/ 

  • vikramsonawane
    Replied on January 25, 2017 at 4:24 AM

    Hi Jim_R,

    We are using iText 7 API (http://itextpdf.com/) and reading the form using Pdf AcroForm API (PdfAcroForm.getAcroForm) & then getting all the fields present on the form using form.getFormFields().

    Issue is that I'm able to see all the fields other than the image field that I originally added during form creation on JotForm website.

  • Support_Management Jotform Support
    Replied on January 25, 2017 at 4:43 AM

    Thanks for clearing that up. Do you have a text dump or log of what you're getting when you use the form.getFormFields() class?

    Adding image to PDF form Image 1 Screenshot 20

    It's a bit hard for us to do blind troubleshooting and debugging. I'm also citing our Developers Forum and API documentation to see if you can find some info on this. We also have a separate and dedicated team that you can reach at api@jotform.com but for now, let us know if you have something that will help us figure out why the image field is not present.

  • vikramsonawane
    Replied on January 25, 2017 at 5:00 AM

    Hi Jim_R,

    Following is the form screen shot.

    Adding image to PDF form Image 1 Screenshot 20

     

    and following is the map content for the getFormFields() method call - 

    {formID=com.itextpdf.forms.fields.PdfTextFormField@610694f1

    website=com.itextpdf.forms.fields.PdfTextFormField@43814d18

    pdf_submission=com.itextpdf.forms.fields.PdfTextFormField@5c5a1b69

    simple_spc=com.itextpdf.forms.fields.PdfTextFormField@3701eaf6

    q15_name[first]=com.itextpdf.forms.fields.PdfTextFormField@627551fb

    q15_name[last]=com.itextpdf.forms.fields.PdfTextFormField@2b552920

    q16_yourEmail16=com.itextpdf.forms.fields.PdfTextFormField@2758fe70

    q22_phoneNumber22[area]=com.itextpdf.forms.fields.PdfTextFormField@1f36e637

    q22_phoneNumber22[phone]=com.itextpdf.forms.fields.PdfTextFormField@578486a3

    q17_yourMessage=com.itextpdf.forms.fields.PdfTextFormField@551aa95a

    q23_preferredContact=com.itextpdf.forms.fields.PdfButtonFormField@35d176f7

    q23_preferredContact.1=com.itextpdf.forms.fields.PdfButtonFormField@1dfe2924

    q23_preferredContact.2=com.itextpdf.forms.fields.PdfButtonFormField@6ebc05a6

    q25_occupation[Owned Business]=com.itextpdf.forms.fields.PdfButtonFormField@6e6c3152

    q25_occupation[Salaried]=com.itextpdf.forms.fields.PdfButtonFormField@50b494a6

    q25_occupation[test]=com.itextpdf.forms.fields.PdfButtonFormField@3cef309d}

     

    If you notice the highlighted text, it hasn't returned the field information pertaining to the form image placeholder.

  • Support_Management Jotform Support
    Replied on January 25, 2017 at 6:21 AM

    That was helpful and you're correct. The Image Field was not included on the map content you posted:

    Adding image to PDF form Image 1 Screenshot 30

    I can only assume that, that method is only gathering "actual input fields" and skips anything that is not an input field (in this case, an Image Field). There's a way for us to test this with your help.

    Try adding a Text Field to your form and run the method again.

    Adding image to PDF form Image 2 Screenshot 41

    If form.getFormFields() will skip that too, then we can safely deduce that it's only generating results from input fields.

  • vikramsonawane
    Replied on January 25, 2017 at 6:44 AM

    Thanks Jim_R, that makes sense. Is there a way I can have image as input field in JotForms?

  • Support_Management Jotform Support
    Replied on January 25, 2017 at 7:50 AM

    Glad everything's cleared up now. But I'm afraid what you're asking is not possible. Textboxes, Checkboxes, Radio Buttons, and any field that requires user input are the only ones considered as input fields.

    The rest that only serves to display information (e.g. Text Field, Image Field, and perhaps our Form Collapse and Page Break tools) can never be considered as an input.

  • vikramsonawane
    Replied on January 27, 2017 at 8:16 AM

    Hi Jim_R,

    Is there a way I could have my own field names. Just to give an example, in my earlier response I have share the content of the fields map:

    ...

    q15_name[first]=com.itextpdf.forms.fields.PdfTextFormField@627551fb

    q15_name[last]=com.itextpdf.forms.fields.PdfTextFormField@2b552920

    q16_yourEmail16=com.itextpdf.forms.fields.PdfTextFormField@2758fe70

    q22_phoneNumber22[area]=com.itextpdf.forms.fields.PdfTextFormField@1f36e637

    ...

    Every field is prefixed with some details (q15_, q16_, etc). In the field level configuration, I just have name, yourEmail16, etc. Why is it adding the suffix & is there a way I could not have that?

  • Chriistian Jotform Support
    Replied on January 27, 2017 at 9:43 AM

    The field name prefix on the provided content cannot be removed or replaced. The prefix (q15_, a16_, etc.) are system generated. You can only update the Unique Name of the field in your form. This is the name that comes after the prefix.

    Adding image to PDF form Image 1 Screenshot 20

    Do let us know if you need further assistance.
    Regards.