Stefan Cameron on Forms
Building intelligent forms using Adobe LiveCycle Designer

Expanding to Fit the Entire Value

A while ago, I posted an article detailing a trick to make the value of a field be displayed entirely within the field’s content area. Essentially, by setting the value font size to zero, this tells Acrobat to shrink the field’s content area (value) font at will to make the entire value entered fit horizontally. This can certainly be useful but there’s one significant drawback: the value font may shrink such that it becomes too small for anyone to read depending on how much data the user enters into the field.

Fortunately, there’s an alternative method to making a value fit within a field’s content area when you don’t know how long the value will be: Making the field’s width and/or height expandable!

The advantage of this solution is that the value font’s size remains constant (the same as which you specified it to be when you designed the form). When a field is made expandable, its "w" (width) and/or "h" (height) attributes are replaced by "minW" (minimum width) and/or "minH" (minimum height) attributes, respectively. These attributes define the initial and minimum size of the entire field (that is, its caption and content areas combined). When the width is extended, however, only the field’s content area is increased in width. Its caption area remains the same width. On the other hand, causing the height of a field’s content area to be extended will also cause the caption area’s height to be extended.

Making a Field Expandable

Specifying that a field’s width and/or height is to expand to fit its content is quite simple: You just need to check the "Expand to fit" check box that pertains to the width and/or height property on the Layout palette.

Getting a Tight Fit

So far, you’ve learned how to make a field’s width and/or height expandable, essentially by specify a minimum width and/or height instead of a set width and/or height. Now what if you wanted to ensure that the field’s width and/or height was always just wide enough to contain whatever value was entered? For example, you don’t want a whole bunch of empty space if you set a minimum width of 2 inches to have a nice initial size to enter a value into the field but the user only entered a value that required 1 inch to be entirely displayed.

In that case, you could simply set the minimum width to zero when the user leaves the field, if they’ve entered a value. This is done by scripting the field’s Exit event (shown here in FormCalc):

$.minW = "0"

Look-out for Long Values!

One thing you have to look-out for is extra long values — especially if you haven’t specified a maximum length for the field. If the user enters too much data, the field might simply run off the page.

If you don’t want to set a maximum data length for the field but you don’t want it to expand beyond a certain width, you can set a maximum width and/or height. Since Designer’s UI doesn’t let you set this property directly, you can use the field’s Initialize script to set it (shown here in JavaScript):

this.maxW = "4.5in"; // max width of 4.5 inches

Note, however, that if the user enters more data than can fit within the specified maximum dimensions, the value will be cut-off and won’t print so you may consider setting a maximum data length or resorting to the previous solution (setting the font size to zero).

Sample

This sample form implements the solution I’ve described in this post.

Download Sample [pdf]

Minimum Requirements: Designer 7.x, Acrobat 7.x.


Posted by Stefan Cameron on October 31st, 2006
Filed under Scripting,Tutorials
Both comments and pings are currently closed.

88 Responses to “Expanding to Fit the Entire Value”

  1. Brad Whitaker on November 8th, 2006

    Is there a way to determine within a script whether or not the text fits within the field? Acrobat/Reader give the visual clue (the + sign) but I can’t find any documentation indicating that this “status” is available programmatically.

  2. Stefan Cameron on November 8th, 2006

    Brad,

    To my knowledge, this kind of information isn’t available via the scripting API.

    If you’re trying to grow the field such that the text always fits, I would suggest you make the field’s width and/or height expandable using the Layout palette. This will ensure that the text always fits (and is always completely visible).

  3. Brad Whitaker on November 9th, 2006

    Thanks for the response. Expanding the field is not appropriate for my application. I wanted to do a kind of “pre-flight” print checking to make sure that all content will be visible within the fixed amount of space that has been allocated. Since I’m using variable width fonts I can’t just restrict the number of characters.

  4. Stefan Cameron on November 11th, 2006

    Brad,

    I think I understand your problem a little better now. You may still have some options:

    • Acrobat 8.0 Dynamic XML Forms: Using Designer 8.0, you can check the “Limit Length to Visible Area” box on the Field tab in the Object palette. This may also work using Designer 8.0 and saving the form as an “Acrobat 7 Dynamic XML Form” but it wouldn’t really be supported.
    • Acrobat 7.x PDF Forms: If you’ve saved your form as an Acrobat 7.x PDF form, you can set the Acrobat Field Object‘s doNotScroll property to “true” in order to limit the value’s length to the field’s visible content area as follows, in JavaScript only:

      event.target.getField(GetFQSOMExp(this)).doNotScroll = true;

      Note that this must be done in the field’s Enter event (when the field receives focus). Doing it in the Initialize event is too soon and you won’t have access to the pertaining Acrobat Field Object in order to set the doNotScroll property.

    In both cases, this will limit users from entering more text than can fit into the content (value) area of a field. It’s different from setting a maximum character length for the field in that it takes variable width fonts and kerning into consideration.

  5. Esther on March 12th, 2007

    I have created a table with auto-fit textbox in the repeating row. Although I have set both Table and Body Row property to “Allow Page Break within Content”, the table still run off the page for bulky input (start from the first row of second page). How can I fix this?

  6. Stefan Cameron on March 15th, 2007

    Esther,

    If I understand correctly, the text field within the table row isn’t splitting in two parts with the beginning on page 1 and the remainder on page 2, for example. Instead, the entire table row gets moved onto page 2.

    To make sure that the text field within the table row is split into two parts, the table must be placed within a flowed container (that is, a subform with its Content Type property set to “Flowed” — set this via the Subform tab in the Object palette) and the table and table row must both have the “Allow Page Breaks within Content” option checked (also set via the Object palette’s Table and Row tabs, respectively).

  7. Esther on March 20th, 2007

    Thanks very much! I just miss the “Flowed Container” that you mentioned.

    I am creating a table with following spec. but the result is not what I expected, so wonder if it is possible in Pro 8:

    One subform container for the table body which just repeats once, and the table body itself contains 10 rows, with column one a positioned subform, so that I can put different elements for each row.

    I can’t make it right as the page break problem happened once again. So it is impossible to make a flowable table with not just using the repeating content?

  8. Stefan Cameron on March 21st, 2007

    Esther,

    A flowed container (subform or table) is required if you’re going to make something within it repeatable.

    You should be able to select the default text object contained in the first column of a row and change its type (via the Object palette Field tab’s Type property) to a subform. This will give you a positioned subform as a table cell. At that point, if you want the subform within the cell to split across pages, I believe you’ll also have to make it flowed. You can always add a further level of nesting using positioned subforms in order to position fields within that subform at precise locations.

  9. Brent on June 8th, 2007

    Hi Stefan,

    I have a question about using javascript to set the width of a cell in a table. Say we have a table with 1 row as well as a header row (named Row1 and HeaderRow). Also, HeaderRow contains the default text object called “Cell1” and so does Row1. So basically I just clicked on “create a simple table” with one column and one body row. I can adjust the heights of the rows with the following code:

    Table1.HeaderRow.Cell1.h = “2in”;

    However, when I try to adjust the width with the following code, nothing happens.

    Table1.HeaderRow.Cell1.w = “2in”;

    I can put a text object on the form and adjust either the height or width, but when it’s bound by a table, I seem to only be able to adjust the height.

    Thanks a lot,
    Brent

  10. Stefan Cameron on June 13th, 2007

    Brent,

    Very good question! In order to understand why you can’t adjust the width of a column the same way you can adjust its height, you need to understand a bit about how tables work in XFA.

    Tables are essentially <subform> structures where the table itself is a subform with a special “table” layout (which is basically a top-bottom flowed layout). It then contains subforms as its children which each represent a row. These subforms also have a special layout which is, you guessed it, “row” (basically a left-right flowed or western text flowed layout with some slight differences). Since these special subforms are flowed, you can use Instance Manager objects to add/remove instances of rows within a table and cells within rows — as you’ve done already.

    Now to get to your question, the height of a row is determined by the tallest cell and all other cells are treated as being that height in the layout even if they aren’t the same height — hence why you can adjust the height of a row by setting the height of a cell.

    The width of a cell, however, is set by the column widths defined on the table subform itself in a special attribute called “columnWidths”. It contains a space-delimited list of columns widths. These measurements override any individual cell widths. Therefore, in order to change the width of a cell, you have to change the width of the column it pertains to in the columnWidths attribute which you simply access as a property on the table subform:

    MyTableSubform.columnWidths

    A suggestion for easily editing this attribute’s value would be to use the JavaScript String object’s “split” method to convert the string list into an array of sizes which you can then manipulate. Although the units (“mm”) will also be part of those numbers, you may specify column widths using other units if you wish.

    Last but not least, if the columns don’t appear to render correctly after you set the new column widths, it’s probably because you need to force the form to be re-rendered by using the following statement (this will apply to Acrobat/Reader 8.0 or earlier):

    xfa.layout.relayout();

    This is a similar bug to the one about adding/removing table columns. This issue is fixed in the Acrobat/Reader 8.1 update.

  11. eDesign4Less on June 18th, 2007

    Hiya Stefan,

    You seem to know your stuff around Adobe Designer. I have a small issue, perhaps you can shed some light on the subject because what I am finding is limited and useless.

    I have a form I am developing with Designer 7.0. For some reason, when I add something random (sometimes an image or even changing text) Designer won’t save. I get an error saying it cannot save because of “PDDocSave”. Now I can figure the problem out if I know what the heck that actually does…. Any ideas?

    Thanks,
    Stephanie

  12. Brent on June 18th, 2007

    Thanks a lot Stefan! I would have never figured out that the column widths are stored in a space-delimited string. This is the first dynamic pdf file I have ever created and you and your site have helped me so much. Thanks again.

  13. Stefan Cameron on June 18th, 2007

    Stephanie (eDesign4Less),

    I believe the error message you’re seeing is

    “Unable to save PDF document. Error during PDDocSave.”

    According to my colleagues, this error message usually occurs when there’s a problem saving a form as a PDF file. Possible causes could be that the PDF file is currently open in another application (thus preventing Designer from writing any changes to it) or that the system ran out of memory while attempting to write to the PDF file (which could explain why it tends to occur, for you, when you’re adding an image object to a form depending on the size of the image file that you load into it).

    I’m sorry I can’t be more specific than that — hopefully this helps.

  14. Tyler on July 19th, 2007

    Hey Stefan,

    I have 3 text fields on a page all set to expand and all set to be the same height. Getting the xfa.layout.h for one text field and setting the minH of the other 2 fields to this height. Now my question is when the text field expands over onto a second page the H does grow past the height of the first page. It tells me the height is 265 mm…when there’s another 100 mm on the second page. I do I get the full height when it’s over onto a second or third or more pages.

    Tyler

  15. Stefan Cameron on August 1st, 2007

    Tyler,

    It took me a little while to figure this one out because the documentation on “xfa.layout.h” isn’t very clear. Essentially, you’ll need to make use of the function’s 3rd parameter which takes a “page offset”. What this means is that you need to give it the zero-based index of the page on which you want to determine the height of the field. For example, if the field spanned 2 pages and you wanted its height on the second page, you would do this:

    xfa.layout.h(TextField1, "in", 1);

    The other important piece is how to determine the page index of the first page on which the object appears as well as the number of pages that it spans. For this information, you’ll need to use the “xfa.layout.page” (to determine the one-based index of the first page on which the object appears — a return value of zero likely means that the object isn’t rendered, probably because it’s hidden) and “xfa.layout.pageSpan” (to determine the number of pages that the object spans).

    By using “xfa.layout.page”, “xfa.layout.pageSpan” and “xfa.layout.h”, you can then iterate through all pages that the object appears on and add the heights in order to determine the total height. Here’s an example (in JavaScript):

    var nFirstPage = xfa.layout.page(TextField1); // returns one-based value
    var nPageSpan = xfa.layout.pageSpan(TextField1);
    var nTotalHeight = 0.0;
    
    for (var i = nFirstPage; i < (nFirstPage + nPageSpan); i++)
    {
      nTotalHeight += xfa.layout.h(TextField1, "in", i - 1); // zero-based page offset required
    }
    
    xfa.host.messageBox("Total height: " + nTotalHeight); // display total height in message box
  16. Hue Ngo on March 12th, 2008

    Hi Stefan,

    I have a few issues with my form that I am trying to create in Adobe Designer 7. First, I have two options using radio button, each options has descriptions/text fields that need to be filled in once checked. Is there a way that if one option is selected, only the selected description/text fields are visible and the other otpion/descriptions/tex fields will be hidden? Second, what is the script for automatically populate information from one field into another because the checkbox was checked? Third, expanding the field automatically, I have been trying everything that I’ve read from this page and it still does not work. I have the text field that will allow mutiple lines, what is it that I am missing in order for the form to grow when more texts are being added.

  17. Stefan Cameron on March 12th, 2008

    Hue Ngo,

    1. To show an option when another is selected, see my article that talks about the other field
    2. To pass a value from one field to another when you exit a field, put a line of script in the Exit event of the source field that does something like “MyOtherField.rawValue = this.rawValue;” (in JavaScript). Make sure you address the form objects correctly if they’re nested in subforms. Usually, if they have unique names, this simple script works.
    3. Make sure that the width and height properties on the Layout palette are set to “Expand to fit” depending on whether the field should grow horizontally and/or vertically. You may also need to put the field inside a flowed subform, along with other form objects that follow it, to ensure that those form objects flow downwards when the field’s height changes.
  18. Kyle on April 3rd, 2008

    Hello Stefan,

    I have two questions.

    Question 1
    I know how to make expandable flowing text fields on multiple pages. But the problem I encounter is when the expandable text field flows onto another page, it creates a new blank page with the expanded text on it. Is there a way to have the expanded text roll over on to the next page of the form, pushing the next pages content down to accomodate it.

    Question 2
    Is there a way to create a text field that has horizontal lines populated in it to accomodate the people that need to hand write in the form while the text perfectly matching up as if it was underlined for the users that electronically fill out the form?

  19. Kyle on April 3rd, 2008

    oops, forgot to add.
    I am using Adobe Acrobat 8 LiveCycle Designer

  20. Stefan Cameron on April 9th, 2008

    Kyle,

    In response to question 1: If the expandable text field is inside a flowed subform, all objects inside that subform that follow that text field as it expands in height will continue to flow on the next page just below the text field.

    In response to question 2: I don’t know of a way to produce horizontal lines. The only thing I can think of that comes close is to specify a comb on the field but this only works for single-lined fields.

  21. Kyle on April 10th, 2008

    Hmmm, I have a subform that encompasses page 2 – page 5, set to flowed with page breaks checked. I think my Hierarchy looks ok, but instead of the expanding text field being on the next page pushing down another text field. It creates a new blank page inbetween for example page2 and page3 instead of the textfield going on page3. Any thoughts?

  22. Kyle on April 11th, 2008

    Figured it out. Thank you for your time Stefan. The problem was, under pagination, I needed to have the subforms that are created for my pages to be “following previous”, it was defaulted to “top of next page”.

  23. Joey on April 21st, 2008

    Hi Stephan,

    I really need your help! I am currently trying to create forms and I would like to make fields that has the capacity to add in lengthy text. Now, what ive done is put a text box where the lengthy text is to be entered. However, I dont want the textbox to expand (due to dynamic text format), but instead flow onto the next page, ( sort of how microsoft word works) I hope you can help me! Thank u!

    Best
    Joey

  24. Stefan Cameron on April 23rd, 2008

    Joey,

    It sounds like you should be giving your text box a set width and an expandable height so that it doesn’t grow in width but just in height. Then you would need to put it in a flowed subform and make sure that the subform’s content can break across pages (both these settings can be found on the “Object palette > Subform tab”). Note that all subforms up to the page subform will need to be flowed in order for the text field to successfully break across the page.

  25. Joey on April 27th, 2008

    Hi Stefan,

    Thanks so much for your reply. I just have another question, in the form that I’ve created, the subform button is not available ( as in it it won’t allow me to click it). I have created this form from an existing document in InDesign. Is that the problem? If I create a new form it will allow me to create a subform. However I need to have the subform available in the existing document to allow me to add text. Please help! and Thank you so much for your time and help..

    Joey

  26. Stefan Cameron on May 1st, 2008

    Joey,

    That’s the problem: When you import a form as “fixed pages” (as you have done with your InDesign document), you cannot use the subform object. Furthermore, you cannot use “dynamic” features such as “expand to fit” on a text field. This is because the PDF you end-up with, while staying true-to-form to your original document layout, is essentially a static PDF which doesn’t support any dynamic features (e.g. showing/hiding fields, growing/shrinking fields, adding/removing subform instances, etc.).

    I’m afraid the only alternative is to import your form as “flowable layout” however I can’t guarantee that you’ll like the results.

  27. Jacelyn on June 27th, 2008

    Hi,

    I have a question, say if I have 1 text field which I want it to be expandable and I have another text object right beside the text field, my problem is when the text field expanded it overlapped with the text object besides it. Is there any way I can expand the textfield and at the same the text object will also move accordingly?

    Thank you.

  28. Stefan Cameron on June 29th, 2008

    Jacelyn,

    The problem with the expandable field overlapping the other field beside it is that the fields aren’t in a flowable container (a subform with flowed content). Therefore the second field is fixed in position on the form. If both fields were in a flowed container and the first expanded, the second would automatically be shifted to the right or downwards (depending on the flow direction) to accommodate for the first field’s new width/height.

    You should be able to select both fields and then right-click and choose “wrap in subform”. That will place both fields in a single subform. Then, with the subform selected, set “Object palette > Subform tab > Content” to “Flowed” and, if you want your fields to remain side-by-side, set “Flow Direction” to “Western Text” (which means “left-to-right, top-to-bottom”).

    If you set the flow direction to “Western Text”, increasing the width of the first field such that the second can no longer fit next to it without going outside the form’s right hand margin should cause the second field to essentially wrap around end-up below the first field (on the “second line”).

  29. Kelly on July 9th, 2008

    Hi Stefan;

    I created a form in Acrobat 8.0 using an MS Word form. It looks fine – the text fields were recognized etc. So far so good. However, I want the fields to expand and I want the entire form to flow and extend on to new pages as text is added to the fields just as it would in word. However the “Expand to Fit” boxes are grayed out for all of my text fields, I also cannot save the form as a Dynamic form as that option does not appear when I save it; my only choices are Acrobat 6/7/8 Static form. I also cannot wrap any of the text boxes in a subform which I read somewhere you needed to do in order to get the form to flow. If I create a new blank form I can save it as Dynamic form so it is extremely puzzling why the converted word form does not allow that option. Do you have any ideas or suggestions for these issues?

    Thank you

  30. Stefan Cameron on July 14th, 2008

    Kelly,

    The issue here is likely with the way you imported your Word document into Designer: When you import the form with “fixed pages” (a.k.a. as “artwork”), the result is an XFA form with the original PDF (or the Word document converted to a PDF) as its background. While the results are aesthetically precise (i.e. it preserves any kind of special layout you might have had in your original document), this type of form cannot be dynamic (e.g. fields in it can’t expand to fit, as you’ve observed, and you can’t have sections that expand or contract, amongst other things).

    If you import your Word document using the “Interactive Form with Flowable Layout” option in Designer, then you’ll get a form that may not look exactly like your original document however you’ll be able to save it as a Dynamic PDF form and make fields and sections expandable.

  31. Nate on August 6th, 2008

    Hi Stefan. I have 2 somewhat related questions.

    Is there a way to determine through scripting which content area(s) a certain subform is contained in? I have a form that’s a 2 column layout, one content area for each column. I’d like to know if a subform with a text field flows from one column to the other — or is contained wholly in one column.

    Also, I’ve been trying to change the heights of content areas during runtime. Ont he same 2-column form, I have a header area that expands based on the amount of text a user types. I’d like the 2 columns to start directly below that header. I’ve been trying to get the height of the header and using that to calculate a new height for a content area. But I can’t seem to make it work. Is this impossible?

    Thanks very much.

  32. sbrof on August 13th, 2008

    Dear Stefan,

    I just found your blog and must thank you for the information I have so far gathered. I am having the same problem as Esther above where my expandable text fields that are placed within a Table Cell don’t flow properly. Instead of information being on both the first and second page the whole table row jumps pages. This is a problem is someone inputs more information than one page can hold and Acrobat doesn’t know what to do anymore.

    I have created text fields in subforms that expand properly no problem. I have also gone into the Object\Table, and Row properties and checked “Allow Page Breaks within Content.” Is there anything that you can think of that would be causing problems. If seeing the file would help I have posted it here

  33. Stefan Cameron on August 13th, 2008

    Nate,

    While it’s possible to determine the page on which a form object is located, I don’t believe it’s possible to determine in which content area on that page it happens to be rendered. You can determine the page using the “xfa.layout.page(object)” function where the parameter is a reference to the form object in question.

    As for resizing content areas at runtime, that’s not possible. There are too many implications with regards to form layout for this to be possible.

  34. Stefan Cameron on August 18th, 2008

    sbrof,

    I think it’s the buttons (MoveUp, MoveDown, RemoveItem) inside the table row that are preventing the breaks within the Item_OT and Issue_OT text fields.

    If you create a new table with a row containing only multi-line, height-expandable text fields as cells and allow page breaks within the content of the table and the row, the fields should break assuming there’s a common break point amongst the content in all fields/cells.

    Also note that this will only work with Designer 8.2 and Acrobat 9.0 since those versions introduce the ability to break field content across page boundaries.

  35. Sylvia on September 1st, 2008

    Hi Stefan, googling for wrapping text inside checkbox sorta point me to your site once again, would you by any chance know how to do this?

  36. Stefan Cameron on September 1st, 2008

    Sylvia,

    I’m quite certain caption text in a checkbox will wrap if you size the caption area large enough to fit the text. If it doesn’t, I think you’ll have to set the checkbox’s “Layout palette > Caption > Placement property” to “None” and use a separate text object for the caption.

  37. Anthony on September 1st, 2008

    Hi Stefan

    I’m using Designer 8, Acrobat 8 and testing on Reader 8.
    I have a table with a few rows and the rows contain TextBox fields.
    They have been set to height expandable so if the text is larger than the box it expands to fit. This works fine.

    I am having trouble with the overflow of a particular row. So if one row expands over more than one page it doesn’t split the cell so that the row stays on the first page and the overflow goes onto the next page. Is this possible?? From your comment above to sbrof, I believe I’m not using the right version. Just need to confirm.

    Thanks in advance

  38. Stefan Cameron on September 9th, 2008

    Anthony,

    That’s right: Splitting text field values between pages is a new feature in Designer 8.2 and Acrobat/Reader 9.

  39. duane on September 14th, 2008

    Hi Stefan,

    Quick question for you … I know this hasn’t been possible in the past, and was wondering if anything has changed in versions 8.1.2 or 9.

    I have an expandable text field, but as the user enters multiple lines of text, the height of the text field remains the same, and a scroll bar appears along the right hand side. The text field does not expand in size until focus is moved away from the field.

    Is there any way to allow the text field to dynamically grow as the user is typing in the text? I don’t think it’s possible (it would seem very expensive to recalculate layout with each line of text entered), but figured I’d ask.

    Thanks.

  40. Stefan Cameron on September 16th, 2008

    duane,

    I know what you mean. I wish it resized in real-time but that hasn’t changed in Acrobat/Reader 9.

  41. Stephanie on October 6th, 2008

    Hi Stefan,

    I’m trying to create the expandable field, just like your reply #28, but it’s not working. I can’t even get the expandable field to work. I’ve checked off “expand to fit” but still…nothing! I’m using Acrobat 9 and livecycle designer. Is there something I’m missing? please help!

  42. Stephanie on October 6th, 2008

    Sorry, to add to that..the field keeps giving me a plus sign and doesn’t expand, even though its checked off as expand to fit. any ideas??

  43. Stefan Cameron on October 9th, 2008

    Stephanie,

    It sounds like your PDF might be static, not dynamic, in which case field expansion will not work. Have a look at my article on previewing a form as a Dynamic PDF.

  44. Christoph on November 17th, 2008

    Hi Stefan,
    I have a document with a fixed layout for the first page and possibly dynamic layout for the following pages.
    I need a multi line text field on the first page that should behave as follows: If the amount of text exceeds the visible part, it should be replaced by something like “for details see last page…”, and then the complete text should appear there. So I think I need the following:
    1. Determine if the field is full, without restricting the number of characters entered.
    2. Create a new field on the last page

    I haven’t tried number 2 yet because I did not succeede with number one. So any idea for queastion 1?

    Thanks

  45. Stefan Cameron on November 19th, 2008

    Christoph,

    Sounds like you need something like the auto-splitting text sample.

  46. Loretta on January 28th, 2009

    I am using LiveCycle 8.2 and want an expandable text field, and the next items to move down to accommodate the text. I have it (along with some other items) in a subform that is “positioned” and the subform below it is also “positioned” but those two subforms are within another subform which is “flowed,” so as I understand it from the other responses, the subform below SHOULD move down to accommodate the expanded text. I have checked off the height as expand to fit, which it does, but it appears over the next set of items. I know this is possible; I have used a form with it, but unfortunately, that form is protected or I’d crib the scripts, etc. Oh, yeah, it is a dynamic form.
    Thanks! This is a GREAT forum!!!!!!

  47. Stefan Cameron on January 30th, 2009

    Loretta,

    In order to get the subform below to move down when the text field’s height expands, everything must be flowed, including the two subforms that are currently positioned. If you need to place objects within those subforms in specific locations around the text field, you can wrap those other objects within positioned subforms of their own.

  48. Robert on February 16th, 2009

    Hi

    Is it possible to make expandable form fields whereby the text box will expand to accommodate all the copy and flow the remaining fields down the document, using Acrobat Pro only?

    Thanks

  49. Stefan Cameron on February 16th, 2009

    Robert,

    If by “using Acrobat Pro only” you mean in an Acrobat Form, not an XFA Designer form, then I don’t believe you can do it but you would be best to ask your question at the acrobatusers.com forum.

    Otherwise, as long as your field is inside a flowed subform and that subform and its siblings are inside a flowed subform (could be the root subform), then when the field expands, the following content will flow down.

  50. Chris on April 13th, 2009

    Hi Stefan,

    Love your site! Question regarding this post. I have a textfield with a default value that is multiple lines entered in my field. The objective is if the user choses not to include this line or part of the line, they can highlight the text and remove it.

    In the object field section I have “Allow multiple lines” checked and in the layout section I have “Expand to fit” selected as well.

    I have the following in the exit under javascript

    this.minH = “0”

    This works to shrink the textfield to the necessary size however, if the user removes the entire text a space remains (which I am guessing is the minimum size for the font). This is not what I want.

    I want if the user removes the entire text from the textfield it makes the text field the size of 0 (like a flowable subform does when it is empty).

    I have tried to add validation script to make the subform it is in “hidden” if the minH – 0 and I have tried if the text field =null but neither work properly.

    I am using LiveCycle ES 8.2

    Any help or advise would be very helpful.

    Thank you in advance for your time.

  51. Stefan Cameron on April 15th, 2009

    Chris,

    You’re correct: Even if the minimum height is 0 and the field doesn’t even have a caption, the field’s height remains at the height needed to show one line of text in its content area.

    I would suggest you simply hide the field on exit if it’s empty. In the text field’s Exit event, just use this script:

    // JavaScript:
    if (this.rawValue == null || this.rawValue.length == 0)
        this.presence = "hidden";
  52. Chris on April 27th, 2009

    Thank you Stefan!

  53. Kevin on May 17th, 2009

    I wont even try to pretend I know what I am doing! Somehow I managed to bumble through the creation of a form with expandable flowed subforms, the form work to a point. Once any of the flowed data reaches the bottom of the page, no 2nd page materializes. Typed info is not viewable, is there some simplistic setting I have over-looked.

    I have checked allow page breaks on every subform that will allow it. Some do not allow it, some have paginantion options. Any help will be great Thanks

  54. Kevin on May 19th, 2009

    Update,

    Stefan I now know what Im doing, form work awesome…on problem how does on add a header or footer to these dynamic documents. Going to document tab in pdf does not allow adding.

    Please help

  55. Stefan Cameron on May 19th, 2009

    Kevin,

    I’m glad you figured it out!

    On adding headers and footers, you would add these to the Master Page. Choose “View > Master Pages” and then resize the content area to give you room for your header and/or footer. (The content area defines the area on the master page where body content flows. Note that resizing the content area will require you to resize your page subforms on the Design View accordingly.)

    With the content area resized properly, you can then place fields/text above and/or below to create a header and/or footer that will be displayed on all pages of your form as they are created with respect to the dynamic content on the Design View.

  56. Kevin on May 20th, 2009

    Stefan,

    What can I say? You the man!!!

    Thanks!

  57. Kevin on May 20th, 2009

    Stefan,

    Im not even sure the program can do I what I am trying, but let me explain. I have a flowed drop box and fillable field text together. The flowed portion seems to work fine. What I would like is for the drop box and and field to replicate as needed…I do not mind if the is one blank row on a form. Is there a setting to make the form replicate this content while it is being filled out. I can set a number of rows, but if I set 10 and only 3 are used that leaves a lot or empty space.

    Kevin

  58. Stefan Cameron on May 25th, 2009

    Kevin,

    You would need to wrap your drop down list and text field into a subform and place that subform inside another subform that has flowed content (“Object palette > Subform tab > Content property” is set to “Flowed”). Then you would make the inner subform, that contains your two fields, repeatable by setting its “Object palette > Binding tab > Repeat Subform for Each Data Item property”.

    Once this is done, you can use the Instance Manager in a script to add/remove instances of the subform containing the two fields. For example, say the inner subform was named “row”. You would do the following to add an instance in the Click event of a button:

    // JavaScript
    row.addInstance(0);
  59. Pat on June 6th, 2009

    I have a successful text field that has $.minW=”0″ and $.maxW=”4″ wrapped in a flows subform with western text flow direction.

    I need to control the entry in that text field so I need it to be a drop down list. Once I change the text field to a drop down list, I cannot make the field expand and contract and the expand checkbox under the layout tab is greyed out.

    What am I doing wrong?

  60. Stefan Cameron on June 8th, 2009

    Pat,

    Unfortunately, drop down lists do not support the “expand to fit” features (and neither do list boxes).

  61. Emmanuel on November 14th, 2009

    Hey Stefan,
    Using 8.2
    Getting desperate… I’m new to livecycle and I have a newbie problem. My document is built like this:
    Subform(positioned)

    Subform (flowed)
    – Table (set to allow breaks)
    I have to add dynamic value fields Inside the cells. So I need my rows height to adjust according to the content. Might sound stupid but I can’t figure it out. I’ve been searching for hours. It seems like a basic thing in all the programs I’ve ever worked with.

  62. Stefan Cameron on November 19th, 2009

    Emmanuel,

    Just make sure your cell fields are set to expand to fit their value vertically (height-wise).

    Note that only certain types of fields can expand to fit their value and when in a table, they can only expand vertically. Having non-expandable fields (e.g. drop down lists) in a row, however, will not preclude other expandable fields in the row (and the row itself) from expanding.

  63. Campbell on December 27th, 2009

    Hi Stefan,

    I am using LC Designer 8.2.

    Q) I am creating drop down lsit box. However, the text of each list item is too long to be visible as it is a long paragraph. May I know if there is any text wrap script available for drop down and list box?

    Thanks

  64. Stefan Cameron on January 5th, 2010

    Campbell,

    Text in listbox and drop down list items cannot be wrapped.

  65. Laurie on January 14th, 2010

    I am attempting to convert an existing Word form to pdf. I have Adobe Pro and Livecycle. If I simply convert the doc to pdf, (by either opening in Acrobat Pro, or simply right-click and convert to pdf) the height auto-expand property on several text fields which exists in the Word form is lost in the pdf. Initially I thought perhaps this was happening because that property does not exist in Acrobat. So I attempted to open the Word form in Livecycle without creating a pdf first. However the option to import with a flowable layout does not appear when importing a Word doc, only when I import a pdf, so the auto-expand property is lost. I realize I can change the auto-expand property once I open the form in Livecycle, however my problem is that I have several documents, many of which are 15+ pages. To modify the properties of each field, the page layout, subforms, etc, etc would be ridiculously time-consuming. Is there a way to import the Word form which will not lose the auto-expand height property? Thanks…

  66. Stefan Cameron on January 19th, 2010

    Laurie,

    I’m afraid I don’t have an answer for you. When you import a Word document directly, the only option is to import with flowable layout so if the auto-expand attribute isn’t being retained, it must be because the import tool doesn’t support/recognize it.

  67. Laurie on January 20th, 2010

    Bummer. Thanks for the reply anyway, Stefan.

  68. Akshat on May 18th, 2010

    hi
    if we have oneTextField and its data size is increasing more than a page how get dispaly that textfield on the form so that data scroll bar should not come

  69. marlaz on May 19th, 2010

    Hello,

    I have read much in your user Forums about LiveCycle Designer.

    I do not know Java or any other code, except a little html which is to me a lot easier.

    I have to re-create a multipage, multi-table form which will be used by people using Acrobat Reader. I need to make this form so that:

    1) The folks can type comments into form fields which expand to fit the text and it shows, so if they want to print it – the text is all there.
    This one I have figured out.

    2) The folks can press a button that will Add Rows to any of the many tables, adding content.
    This one I also figured out.

    3) The folks can press a button that will Delete a Row if they need to. In one of the forum threads I see:

    _Row1.removeInstance(this.parent.index);

    But I don’t know if this is a literal line of code or if the (this.parent.index) means something else. I have attached what I have done so far. The buttons and the table below them are from another source. So far –
    THIS ONE I CANNOT FIGURE OUT.

    4) In Acrobat Reader they can SAVE THE FORMS WITH THE DATA IN THEM and return to finish when they have more input.
    THIS ONE I CANNOT FIGURE OUT.

    Can you help me figure these out?

    Thank you so much – I have one more day to get it done.

    MarlaZ

  70. Senthilkumar on May 22nd, 2010

    how to find out line number in pdf

  71. Stefan Cameron on May 26th, 2010

    @Akshat,

    If I understand correctly, you want the text field to grow to accommodate the text rather than remaining the same size and showing a scroll bar.

    If that’s the case, just select the text field and check the “Expand to fit” checkbox for the height property on the Layout palette. Also make sure that the text field is in a flowed subform, as well as content following the text field, so that the text field can grow beyond a page in length and content below it will flow down. Finally, set the “Object palette > Field tab > Allow page breaks within content property” for the text field so that it can be split between pages.

  72. Stefan Cameron on May 26th, 2010

    @Senthilkumar,

    In what context or for what purpose are you trying to determine the line number?

  73. Stefan Cameron on May 26th, 2010

    @marlaz,

    For removing the row, provided your repeatable row is named “Row1” and the code you specified is executed from a field (typically a button) inside the row to be deleted, the code should work. For a sample, see my Sample Form with Row Remove Button.

    As for saving the form in Reader, this functionality is not enabled in Reader by default. It requires the PDF to be extended to allow local save. This can be achieved by either using the “Advanced menu > Extend features in Adobe Reader” command in Acrobat Pro (though there are licensing restrictions on its use — see the EULA) or by using LiveCycle Reader Extensions (assuming you have a LiveCycle server as well).

  74. marlaz on May 26th, 2010

    Hi Stefan,

    Thanks for your help. I have a few other questions which if you could tell me if they can be done and how, I would be greatly indebted to you.

    1) is there a way to place an editable field, as a header, that the Controller of the form would fill out and then lock – so that the users could then fill out the form but not have access to the Controller information? The kind of information I am talking about would be Revision and Document numbers, Effective dates, and so on.

    2) is there a way to add a “page number” to each ‘page’ – perhaps by adding some code after so many lines of code. And is there a quick way to turn on code count instead of me counting line by line?

    I am using LiveCycle Designer ES 8.2 and have never used it before, and have not had any s/w coding experience.
    I need to get these things done.
    Thanks so much!

  75. marlaz on May 26th, 2010

    Stefan, another question – My form looks ok, though it still needs some work, if I open it in Acrobat. I set it so that users of Reader can open, add information, and save the .pdf.

    However, I notice that some of the table rows (which are not visible in LC Designer or in Acrobat) repeat when viewed in Reader. Not very nice and I don’t know what code to look for. Another person was helping me with this but I just don’t know enough to fix this.

    Any ideas?

    Thanks again

  76. Stefan Cameron on June 6th, 2010

    @marlaz,

    “Lockable Editable Field”: Yes and no. You can control a field’s editability by setting the “access” attribute on a field to “readOnly”. You could then set this attribute in the field’s Initialize event if there some piece of data that’s filled-in that only a Controller would fill-in. For example, if the document number is filled, then you know you have the Controller’s information so you can “lock” the Controller’s fields to prevent the current user from editing them.

    “Page number”: Yes, switch to “View > Master Page”, drag text object onto the master page (which is essentially the static background for all body pages in your form), type “Page “, then choose “Insert > Page Number”, then type ” of “, then choose “Insert > Number of Pages”. Make sure you place this text object outside the pink border which identifies the content area (this pink area is where body content will appear one every master page generated, one for each page).

    “Table rows repeating in Reader”: That’s strange — especially if they only repeat in Reader and not in Acrobat. The only reason I can think of is that the PDF you’re opening in Reader has data for that table saved with it and the data is being loaded when the form is open, creating the row instances.

  77. Tanya on June 14th, 2010

    I have several text fields but I want the text to wrap to another line in Adobe Lifecycle Designer. Example
    ________________________________
    ________________________________
    ________________________________

    Whenever I type on the text field line it only stops at the end of the line and will not wrap to next text field. If I check multiple line, it will only wrap on the same line instead of wrapping to next text field. How do I wrap text to another text field or is there another way to do this?

    Thanks

  78. marlaz on June 14th, 2010

    Hi Stefan,
    thanks for all of your help! I was able to complete my forms and they work great!

    I have a new form to begin. This time, the Form user will have attachments that they will want to somehow link into or attach to the Form that I create.

    What is the way that users will be able to add their attachment(s) to my form? Will they need access to LCD? Can they do something like this in Adobe Reader, as I will have given them the extended permissions?

    I bought the book Creating Dynamic Forms wtih Adobe LDC by J.P. Terry but it doesn’t address this or several other issues that would have been nice to know.

    Thanks for your anticipated answers!

  79. marlaz on June 15th, 2010

    Good Morning Stefan,

    I have another question… Requests for new functions and designs come in every day.. This one is to add a required Revision table only at the end of the form. I was thinking of adding it to the Master Page somehow, but I would need to use a second master page to make the table be only on the last page.

    BACKGROUND:
    I have one Master page at this time; it has repeating information on each form page. This is how it needs to be.

    How can I add a “last Master page” – or – a required table for revisions that needs to appear at the very end of a form.

    Because only those in control of the doc revision will have access to the fields, I think the table needs to be on a Master Page. I could be wrong.

    I guess my real question is: How and where do I place a Master Page that appears at the end of the document only, not on each page. Or if I don’t need it on a Master Page, do I protect it somehow but allow the Doc team access so they can revise it when needed?

  80. Stefan Cameron on June 23rd, 2010

    @Tanya,

    Unfortunately, there’s no easy way to do this. Text doesn’t “flow” from one text field to another without some cleaver coding (not exactly what you want, but the principle is the same).

  81. Stefan Cameron on June 23rd, 2010

    @marlaz (June 14, 2010),

    As long as the PDF form has been extended to allow attachments, you should be able to add attachments using Reader. Acrobat always allows adding attachments.

    Designer cannot be used to add attachments to the PDF and editing a form (in Designer) that has attachments may cause those attachments to be lost.

  82. Stefan Cameron on June 29th, 2010

    @marlaz (June 15, 2010),

    You can for a master page to be used only on the last page of a form by using XFA’s Simplex/Duplex feature which you can activate by selecting a pageSet (named “(Master Pages)” in the Hierarchy palette) then setting the “Object palette > Page Set tab > Printing property” to something other than “Page Occurrence”. Then select a master page and set its “Object palette > Pagination tab > Master Page Applies To > Placement property” to “Last Page (in Page Set)”. Then you can set the table’s pagination to place it on that special master page, thereby ensuring that the table ends-up on the last page.

    But even simpler is just to make your body pages flow and put your table inside a subform that is as tall as a page, doesn’t allow page breaks in its content and is located after all other content in the form. This will also ensure that the table ends-up on the last page (and on a page of its own).

  83. Chris on July 9th, 2010

    Hi Stefan,

    Like most people I have a problem.

    I am using LiveCycle 8.2 ES to develop a dynamic flowing form. This form, when opened in Acrobat 8 or 9 will import data from an xml file and populate floating fields accordingly.

    I have 1 master page with a current page number, and a floating field. Both have to be placed in a specific place on the form to meet state regulations and this is why they are on the master page.

    My issue is when I import the data the floating field on the master page will populate on the first page but not on any others while the current page continues to populate accordingly.

    I would like to keep the floating field on the master page if at all possible since I have tried to use the footer option available but to no success. It keeps placing the footer at the very end of the content not in the specific are of the form where it needs to be.

    I appreciate any assistance you can provide.

    thank you for your time

  84. Stefan Cameron on July 19th, 2010

    @Chris,

    You call the field on the master page a “floating field”. To me, that means a field that you inserted into a text object by clicking in a text object and choosing the “Insert > Floating Field”. Is that really what you mean?

    The page number is a floating field as well, but it gets its value programmatically, not from data.

    Your other field likely has a data binding. What kind of data are you wanting to merge into this field and what is the desired result? Is it one value per page?

  85. Jennie on August 25th, 2010

    Hi Stephan,
    First, I am a new user and have just started using LiveCycle Designer 8. I am using Windows.
    I am having difficulty with a custom form.
    -I currently have a header and footer on the Master Page.
    -On the Design Page, I have inserted a table.
    -The Text Fields in the table are expandable.
    -I have read your article about “previewing a form as a Dynamic PDF” and have made sure the form is saved correctly.
    Here are the issues:
    -I need the table to automatically flow into the next page without overlapping the footer at the bottom or the header at the top and have tried to use the Subform feature with no success.
    -I may not understand exactly how the Subform works, but when set to ‘Flowed’ it rolls up and will not allow me to expand.
    -If I get the Subform working should the Subform cover the entire table?
    Thank you for any help you can offer.

  86. Ben on September 1st, 2010

    Hi Stefan,

    I’m fairly new to LiveCycle too, and was wondering if there’s any way to set the Master Page height dynamically based on the height of the subform that contains my input fields?

    My forms aren’t intended to be printed, so what I’m trying to do is eliminate any pagination that is caused as the various fields are made visible/hidden.

    I started to solve the problem by manually setting the Paper Type (in the master page tab) to ‘custom’, then choosing a height that would acommodate all the fields if they were visible, but this meant there was often a lot of white space at the bottom of the form. So next I tried to set the master page height to the same as the subform that contains the fields – and that’s where I’ve got stuck. I’ve tried manually setting the paper type to custom, then changing the master page height using:

    form1.#subform[0].Button1::click – (JavaScript, client)
    var newHeight = xfa.layout.h(xfa.resolveNode(“form1.#subform”), “in”);
    xfa.form.form1.Page1.h = newHeight + “in”;

    …but I’m having no luck and I’d be grateful for any help!

    Thanks in advance

    Ben

  87. Stefan Cameron on September 10th, 2010

    @Jennie,

    It’s good that you have your header and footer on the master page. All you need to do is make sure that the content area (rectangle with a pink-ish border on the master page as well) does not overlap your header and footer. The content area (there can be more than one) determines where content from the body pages can flow into pages generated at runtime. Therefore, to ensure you table doesn’t overlap your header and footer, make sure the content area restricts it to the space in-between them.

  88. Stefan Cameron on September 10th, 2010

    @Ben,

    Unfortunately, I don’t believe it’s possible to alter the height of master pages (and even the content areas that they contain) at runtime. The implications to the layout engine would be large.

    You can, however, change what page a subform is placed on at runtime. That means you would have to have some preset master pages and you would choose the one that is the best fit.

    To change the page on which a body page subform is placed, you can do this:

    // JavaScript:
    BodyPage.resolveNode("#breakBefore").target = "Page2";
    xfa.layout.relayout();
    

    The script above assumes that you have configured the BodyPage subform to be initially placed on a specific page (e.g. a default page) otherwise it won’t work because the < element won’t exist for the BodyPage subform. You can place a subform on a page by setting the “Object palette > Pagination tab > Place property” to “On Page {X}”.