Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Image File Size


Level 1

I'm trying to create a form whereby persons filling out the form can upload an image to the form. I've been able to figure out how to set the Image Dimensions and sizing (scale image to fit rectangle).. however, is it possible to restrict the image size ie: 999kb on the form?

The reason is that i'm trying to limit the final file size of the form.. for the ease of emailing.

Your help is greatly appreciated!

Thank you.

5 Replies


Former Community Member

John Brinkman wrote a nice blog about this and has sample code to do it for you. See the link below:




Level 1

Thank you so much for your quick response!

I was more searching for a code that would automatically resize the image. ie: a 2.5mb to 100kb upon upload. Is this possible?


Level 4

Hi there,

This option is a bit work intensive, but it's what I've been doing when a form is bloated by large images. It requires the you have Adobe Acrobat Pro, and assumes that the person you are emailing the filled in form will not have to make any changes.

1) First, use a virtual printer to "convert" the XFA form to an Acro form (both are .PDF files, but they have completely different internal structures. XFA forms are dynamic XML forms, while Acro forms are the standard static variety).

          - Open your form in Acrobat or Reader, hit File --> Print, then select thevirtual printer from the printer list. If you have Acrobat installed, you probable already have 'Adobe PDF' listed as a printer. If not, you can download and install CutePDF. It's free, easy to use and works great.Instead of physically printing, it'll prompt you to 'Save As.' I suggest saving as a new file, not overtop the original. 'Printin' alone can reduce the file size a bit, as it gets rid of any non-visible form elements.

2) Open the newly 'printed' form, then use Acrobat's built in PDF file optimization tool to compress the images in the PDF. You can fiddle with the settings until you get a satisfactory file size/image quality. How you do this depends on the version of Acrobat that you have, and you can find plenty of tutorial online.

The reason why you have to 'Print' it first is because the built in Optimizer doesn't inherantly work with Dynamic forms. Keep in mind, however, that 'printing' the form prevents any further changes to be made. This is why I suggest saving it as a new file, and keeping the original in case you need to make any further changes.

I know it's not fast and easy, but I think it may be your only solution, outside of outright disallowing large image files to be used.

Let me know if you want to me clarify anything,

- Scott


Level 1

Thanks for your response Scott!

I was more searching for a code i could use on my form, where once sent to my employees..they are able to fill out and email back to me with no issues. So for this, i need to restrict the file size of the images they are uploading ont the form.

What I am searching for is-  as they are upload the images the image is automatically re-sized depending on what size limit i set it to, ie: a 2mb imageis automatically re-sized to 100kb - before it is emailed back to me.

Is this possible?

I hope i am being clear.

Thank you!