by John Brinkman
In your form design you have two choices when it comes to labelling your fields. You can either place the descriptive label text in a field caption or you can create a separate text object with the label text.
There are pros and cons to each, but today I am going to try and convince you to use captions — and give you a tool to make it easier to create captions.
Whether your descriptive text is stored as a separate object or whether it is specified as a caption, in most cases we can achieve the same visual effect with either. Admittedly there are some layout conditions where a caption cannot be used. e.g. where the label extends both above and to the left of the field. But this is the exception.
The advantages of using separate objects:
- Absolute control over label positioning
- Can be less effort to author in this mode
The advantages of using captions:
- Far better accessibility experience
- Results in smaller form templates with better performance
- Lower form maintenance
Field captions can be used to generate a good accessible experience. The caption text can be used as the text that the screen reader uses to describe the field. Obviously when it is stored as a separate object we do not have this correlation. When the label is a separate object, we have extra “noise” as the screen reader traverses the read order of the document. The read order will encounter the label and the field as objects that will be read separately. If they’re not consecutive in the read order, there is potential for even more confusion.
As I’ve mentioned before, form size matters. If your form is delivered with rights enabled and/or with certification, the time to open the form is directly impacted by the size of the form template. This is because both RE and certification use encryption and we need to validate that the form has not been tampered with at open time. To make a long story short, the validation involves loading the form template more than once. If there are fewer objects and less syntax, the form will load faster and open time will be reduced.
Lower form maintenance
When a caption is combined with a field, then all operations treat the field and caption atomically:
- A script to make a field invisible will also hide the caption.
- A page break will never separate a field from its caption, but could separate a field from label text.
- Moving or deleting a field in Designer automatically does the same for the caption.
The Form Conversion Problem
My suspicion is that very few form authors consciously choose to separate the label from the field. In most cases this is a byproduct of a conversion process from some other format to XDP. The form author’s starting point is a form design where all fields are separated from their caption. The question becomes: is it worth the time and effort for an author to combine these objects? Is the net gain worth the investment? The answer is dependent on your own scenario — and dependent on the amount of effort to fix the form.
Designer has a built-in function that will combine text and field into a combined field with caption. You select the text and the field and choose “Layout/Merge as Caption”. The problem you’ll find is that while designer does combine the objects, it does not preserve the layout, positioning, font and paragraph properties of the label when converted to a caption. I think you will see this function improve in future versions of Designer. But in the mean time, this is also a function that can be customized using a designer macro. Here is a designer macro you can install that will combine labels with fields when the label is positioned above the field.
You should find that the macro works fairly hard to give you a finished result with the same visual appearance as the original. Here is a sample PDF with the separated label/text on the left and the combined result on the right.
As I was writing the macro, I realized there are cases where the end-user might want a different behaviour than I’ve provided. For example, when the caption is wider than the field, should we expand the field to match the width of the caption? That was the choice I made. If you prefer a different result, you can tailor the macro to your own needs.
Enjoy. Hopefully there’s enough of a starting point here that someone could expand the macro to also handle captions placement to the left/right/bottom of fields.