Expand my Community achievements bar.

SOLVED

Rotate image

Avatar

Level 2

I need to create a button and script that will rotate an image. I have looked online for javascript, but was unable to find it.

Can anyone help?

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

This should work in the click event of the button:

ImageField1.rotate = "90";

Setting it back to "0" will restore the rotation.

Hope that helps,

Niall

ps: Just did a quick test here and it looks like you need to relayout the form after setting the rotation:

ImageField1.rotate = "90";

xfa.layout.relayout();

View solution in original post

3 Replies

Avatar

Correct answer by
Level 10

Hi,

This should work in the click event of the button:

ImageField1.rotate = "90";

Setting it back to "0" will restore the rotation.

Hope that helps,

Niall

ps: Just did a quick test here and it looks like you need to relayout the form after setting the rotation:

ImageField1.rotate = "90";

xfa.layout.relayout();

Avatar

Level 1

Hi Niall, please forgive my complete lack of knowledge concerning anything livecycle, but it sounds as if you may be able to help me.

I am creating an interactive PDF whereby images can be inserted using the 'image field' object and then printed out to fit templates I've created within the page. This works fine, however I would really like to include a button that would then allow the end user to either rotate or rescale the image filling the space i've provided them with. I have tried entering the code you've posted above, but, to be honest coding is really beyond my comfort zone. I get lost when javascript and formcalc are invloved.

Many thanks for any help you can provide...

Danny

Avatar

Level 3

This... didn't work for me.

Creating a button that uses

ImageField1.rotate = "90";

rotates the FIELD, but not the image contained inside. So it rotates fine, but it doesn't resize the content. I can see this making somewhat of a mess in flowable content forms, too.

Adding

xfa.layout.relayout();

messes it up. I'm not sure what it's doing, or how, but it pushed my picture way off-page somehow. You can see just the edge of the picture going off the page:

pic.png