Expand my Community achievements bar.

Centeral alignment in flowing (L-R) form (hAlign?)

Avatar

Level 2

Hello,

I have a flowed subform (western text) containing some text and a text field which is expandable widthways. I would like the overall text (i.e. the entire content of the subform) to be centered in the page (the form is as wide as the page). I have managed to achieve this temporarily by setting all of its contents' hAlign property to "center" using javascript; but whatever event I set this on it seems to only take effect once the text field expands rather than when the form is first loaded. Also it reverts to left alignment when other parts of the form change layout.

Am I using the wrong event as a trigger or is there a better way to do this?

Many thanks in advance,

Richard

19 Replies

Avatar

Former Community Member

Not sure I follow .....do you want it so that when the user enters data it is left justified but when they exit the text is centered?

Paul

Avatar

Level 2

Hi Paul,

Thanks for your reply. I'd just like the content always to be centered. The left justification is what it's doing now that's wrong. I don't mind if it does something strange while they're filling the text field so long as it is centered the rest of the time.

Richard

Avatar

Former Community Member

Then why not just hit the centered text button in the Paragraph palette for that field. Make sure that you are only adjusting the value and not the caption. here is a screen shot. The Paragraph palette can be enabled under the Window menu or hit Shift F5 to toggle the menu.

Paul

screen1.png

Avatar

Level 2

Hi Paul,

Thanks for another quick reply. I've probably not been clear enough as I don't think that solves my problem. What I want is the fields (3 of them) centered in the subform. What I have is a title at the top of my form, of which the middle part is user-entered and the rest is read only. It reads something like "Project <user entered> Register", where the user enters the project name. The part they enter is expandable so the whole lot needs to be in a flowed subform. What I'm after is how to center the whole content (text, textfield, text) in the middle of the subform. (I actually have it as read-only textfield, textfield, read-only textfield as I've been playing with other properties that didn't work with plain text). Hope that's cleared things up somewhat... and I hope you can help!

Thanks for your time,

Richard

Avatar

Former Community Member

Can you post a sample so I can see and play with it?

Paul

Avatar

Level 2

Sure. Here you go.

You'll see I've got the code in initialize for the subform "Title" but I've tried it in a few other places too.

Thanks for your help,

Richard

Avatar

Former Community Member

I moved the code to the layout Ready event and it works when the field expands (as you exit the field). Is that sufficient? If you enter in a number that does not expand the field then no relayout occurs and thus it does not work.

paul

Avatar

Level 2

That's what it did anyway isn't it? The problem is when I click add row it'll go back to the left. Also if I go over the page it'll be wrong on the next page as the code will only change it for page 1 but that's fixable. Can you make it so it doesn't revert back to left justification when you press add row or add section? The fact that hAlign clearly works at some point makes me think I just need it on the right event to centre the text whenever it's asked to do the layout...

In answer to your question: it's fine if it's not set up right initially so long as once you've entered the text it will stay in the middle regardless of what else you do. I can make the box small enough initially that it will expand for any sensible project name.

Thanks,

Richard

Avatar

Former Community Member

Now I understand ....try this version. Note that if you enter a very long number in it can break over two lines. Oh and it didn't need any code!

Paul

Avatar

Level 2

Been Queued for a while... I'll take a look in the morning. Sounds promising though. Thanks very much Paul.

Richard

Avatar

Level 2

Hi Paul,

It's still not quite there: I'm not sure what you did to make it centre... but it still jumps back to left justification if you press add row (for some reason you have to press it twice). I'm not sure why you need a subform inside the subform containing everything... But it did give me an idea: Can you have R-L Flowed subforms? As then i could just nest some subforms going L-R, R-L, L-R, R-L... so it would fill each one then expand back in the other direction.

Thanks,

Richard

Avatar

Former Community Member

Its not jumping to the left for me ...I am using Acrobat 9.

There is no option to flow right to left....only left to right.

Paul

Avatar

Level 2

Hi Paul,

I'm using Acrobat 9 too and mine's still jumping back to the left of the internal subform... It happens if i press add row twice. What did you do to make it center? Do you have any other ideas as this clearly isn't working for me? If I did use javascript what event should it be on so that every time I load/refresh the subform it positions it where the code tells it to?

Thanks for your continued help,

Richard

Avatar

Former Community Member

I changed the way that subform worked. I made the main sibform of the Title (called Title) Positioned and then wrapped the 3 fields in a fowed subform (so that they can only flow within the space of the positioned subform). Then using the Layout tools (highlighting the flowed unNamed subform) I chose to center horizontally. This will keep the unnamed subform centered in the Title subform. There is no code in my solution....hence there is no event to worry about.

Paul

Avatar

Level 2

Hi again Paul,

Layout -> center horizontally just positions it there, it doesn't do anything to keep it there once it expands or the page is altered. I've set the unnamed subform's width to expand to fit so that the width is that of the text and the text would be truly centered and now the text doesn't move at all. Clearly this is not a solution at all! Argh! As you uploaded it it was centering in the unnamed subform and jumping back - which is the same as I had before, except that you've somehow done it with no code! I think I might just make all the text one field and rely on the users not to mess up the title. (Unless you have a sudden flash of inspiration). Doesn't look like this is possible. :-(

Thanks for all your help anyway Paul,

Richard

Avatar

Former Community Member

I didn't mention that I kept the flowed subform as flowing as Western Text (left to right) so that after the text is entered and the layout happens again the text gets centered automatically. My concern is why it is not happening on yours (unless I am not duplictaing the error).

Paul

Avatar

Level 2

Hi Paul,

That is odd that it centers automatically for you. I thought I might have accidentally changed something so redownloaded your version and opened it in reader 9 without touching anything. I still get the same results. It centers in the inside subform (off to the right) when the field expands and it jumps back to the left when I press add row twice. You're sure this doesn't happen for you? You haven't changed anything since the version you posted? I'm very confused...

Thanks,

Richard

Avatar

Former Community Member

OK Now I see what you mean. When you add two rows we are forcing a new page and the layout is redone ....hence it centers again. I played with it somemore and I do not think I will be able to improve it. How big is a project number? The bigger the number the worse it is. Its the width of the entire unnamed subform that is being centered. You can play with its width to try and do a better job of centering it. It is difficult without knowing the normal size of the Project ID field.

Paul

Avatar

Level 2

Hi Paul,

It can be almost any size hence me wanting this functionality rather than just putting it in roughly the right place. Thanks for your efforts but I guess I'll just make the whole lot a big text field with centered text and rely on them not to mess it up.

Richard