Create PDF Forms with LibreOffice
PDF is normally used as a final publishing format for sending documents that are complete and the receiver only read.
It is less known that PDF has an option which allow to create a form that can be edited and saved by the receiving user. Most standard PDF viewers can be used to edit the form. This provides a simple practical method to publish forms that a user can fill out by the keyboard rather than on paper.
The form makes it clear to the user what fields should be filled out and user editing does not risk breaking the layout of the form.
Updating a PDF Form
To test an example of a PDF form download and open the following PDF file.
Download: PDF Form Example
The example PDF can be opened and edited with a standard PDF viewer. E.g.:
When updating of the fields are complete, save the form using menu File - Save.
Note for Adobe Acrobat Reader: Use version 11 or newer. In earlier versions it is difficult to save the updated PDF form. Details.
Creating a PDF Form
LibreOffice can create PDF files that are essentially the printer output put into a file. This is done with menu File - "Export as PDF...". All documents types: Text, spreadsheets, slide-shows can be output as PDF like that. These files are for reading only, they are not forms.
To create a PDF form LibreOffice Writer (the word-processor) is used. For each user input special fields need to be inserted. To insert and edit these fields use the special menu toolbar "Form Controls". To use the "Form Controls" toolbar select menu View - Toolbars - "Form Controls". This will open a small menu with typical GUI elements, such as text edit boxes and list boxes.
One important button is the icon of the hand with pointy finger on the button. It is design mode on / off, toggling between design and view mode, think of it like enable / disable the menu.
An example says more than a thousand explanations. So to get started download the following form example, which is an OpenDocument text and open it in LibreOffice.
Download: Form Example as OpenDocument Text (ODT)
Note: If the file is opened directly from the download link, it will open in LibreOffice as read-only, so no edit possible. In this case, in LibreOffice use menu File - "Save As..." to save the file to a new location. The new file is now editable.
The example form contains most of the typical fields. They are:
- Check box - a flag field that can be ticked or un-ticked, see e.g. language check box fields.
- Text box - a simple text edit, see e.g. Family Name field.
- List box - a list box where user selects one of the listed elements. See Gender field.
- Combo box - a combined list and text box; i.e. user can either use list or type a new text. See Country field.
These field types should be enough to make most forms. To keep it simple, it is recommend to only use these for the time being. Some of the other field types, may or may not work correctly with all PDF viewers and LibreOffice.
One special field type is radio buttons (in LibreOffice called option button). Radio buttons do not work well with the combination of current (Apr 2012) versions of LibreOffice and PDF viewers. In place of the radio buttons, use a list box.
To add a new field click in Form Controls, cursor becomes plus shaped, place the plus in the document and drag out the field size. The precise field size can be adjusted later.
To view and edit the properties of a field, simply double click on the field.
Note: If double clicking a field does not open the properties window, check that design mode is on in the Form Controls menu. See above.
It is important that fields are tall enough for the font used. If the font is set to Arial 11 pts., the field should be at least 7 mm high. If too small, it might look correct in one PDF viewer, but top or bottom are cut off in another.
It is recommend to set anchor to "As Character", because it makes the positioning of the fields and change of position the most easy.
For List Box and Combo Box use property "List entries" to set the items in the list. Click triangle down icon and write one item per line. Note: Use Shift Enter to add each new line. Just using Enter will close the list.
To make a new layout with other input fields, copy fields and change their properties.
In the properties set the name of each field to a unique name. It is most simple to name a field as its question and include the field type. E.g. the first address field is named "Address 1 Text Box".
When all fields have been added and arranged on the page, it is time to set the tab order. The tab order set the sequence that the user can jump from field to field when using the tab key. To set the tab order select any field and in properties window, at "Tab Order" click the "..." button on the right. A new window will open listing all the names of all the fields on the page. Use "Automatic Sort" to re-order the fields in simple order of their page position.
Output as PDF
When the form is completed, save the document as ODT (OpenDocument Text). The document will be needed to correct mistakes or later update the form.
To generate the PDF output from the document, use menu File - "Export as PDF...". A "PDF Options" window will be displayed. On the General tab, make sure that the check box PDF/A-1a is un-ticked and the check box "Create PDF form" is ticked. It is recommended to set "Submit format" to FDF. Click Export button.
Note: For a normal PDF file which should be a read-only page, it is recommended to tick the option PDF/A-1a. This creates a PDF archive file complete with font information etc. embedded. However for PDF forms this option cannot be used.
It is recommended to test the generated file, to see that all is working as expected.
To fill out the form, make sure the PDF file is not read-only. If the file is read-only save it first to a folder or the computer desktop. Close the current file and open the saved file.
When all appear to be correct, re-test with one or two other PDF viewers as not all PDF viewers work the same way.
For this article the following PDF viewers were tested:
- Tracker Software PDF-XChange viewer, version 2.5
- Foxit Reader, version 7.3
- Nitro Reader, version 5.0
- Adobe Acrobat Reader DC, version 2018
The document and PDF form have been created with LibreOffice (version 5.4.5). As an alternative to LibreOffice the twin-sister office application suite OpenOffice may also be used, for details see Create PDF Forms with OpenOffice.
Notes for old Adobe Acrobat Reader
Adobe Reader version 11 allows to save forms as described above. For Adobe Reader 10 and earlier versions there is a more convoluted system of add-on services that includes a signing and uploading to Adobe's servers. To simply save an updated form do the following steps: In the toolbar click on Sign. A menu will appear to the right of the document. Click "Done Signing". A pop up window "Done Signing" may appear, here click confirm. A "Save As" dialogue window will appear, change folder or file name if needed and click Save. A pop up window "Deliver Your Signed Document" will appear, here click "Not Now". Whew - Finally done! To avoid these complex steps it is recommended to update to current Adobe Acrobat Reader or use a different PDF viewer.
Tags: PDF Form, LibreOffice
Page link: <http://foersom.org/HowTo/CreatePdfForm.html>