These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

How to place an image at the centre of the image field?

aauyeung
Registered: Feb 16 2011
Posts: 4

I set the image field Sizing as "Scale Image Proportionately" and would like the image placed at the centre of the box. How to do that? The image is always left-aligned.

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Use this JavaScript in the enter:Event of the image field.

this.para.hAlign = "center";

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

aauyeung
Registered: Feb 16 2011
Posts: 4
I have tried your method but is not working. I even saved the file with a new name and test it but it didn't work. Can you please help? Any more thing that I need to set? Is it possible for me to send you the file to look at it?


radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Hi,

this is generally very simple to realize.
Not shure what you're doing wrong.

Anyway, here's a sample you can work with.
https://acrobat.com/#d=ZahmLr8JVifLmHgwmyp7XQ

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

aauyeung
Registered: Feb 16 2011
Posts: 4
I tried coping and pasting your image field to my file but the script didn't function and the image is still left aligned. (I have checked the script and it is there.) I compared your file with mine and I found that at the Layout tab, the field "Expand to fit" and "Anchor" is greyed out. Does it relating to the setting at all, do I need to reinstall the LiveCycle Designer?

radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Well,

I think you have imported an existing PDF file into Designer and created a dynamic form.
In this case there are many properties not available (greyed out or simply not working).

To get it work you need one more line of code:
  1. this.para.hAlign = "center";
  2. xfa.layout.relayout();

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

aauyeung
Registered: Feb 16 2011
Posts: 4
I have tried your scripts but still didn't work.

You are correct that I used an existing PDF file to make this form. After I open the original file at LiveCycle Designer, I add the image field. Then, I added the scripts that you provided, saved the file. I closed the file and opened it again by using Adobe Acrobat Pro and click Advanced > Extend Features in Adobe Reader and saved it with another file name. However, the image is still left-aligned.Can you think of anything that I did wrong in the process?

Thanks a lot.

jodzeee
Registered: Sep 29 2009
Posts: 12
Did you ever get this resolved? I'm also trying to figure out how to center an image within a field.
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
The conclusion on this: The script above to center an image in a image field is only working for dynamic forms.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Here an update,

I found a trick to resolve this issue in static forms.
As Designer works as a server, you can manipulate the alignment of image fields even on static forms in the following way:

1. Create a form from an existing PDF file with a fixed layout
2. Add an image field in Designer and insert an image as a placeholder.
3. Add the script this.para.hAlign = "center"; to the initialize:Event of the image field
4. View the file in the PDF-Preview
5. Press Esc in the PDF-Preview window, so the Acrobat menu becomes visible*
6. Save the form with Acrobat's save button

* = doesn't work with Adobe Reader, only Acrobat

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs