All Articles

Creating a Fillable PDF on Ubuntu

Today I had to convert a Word document into a fillable PDF. On Word on Windows, you can do this by enabling developer tools in the ribbon and using the form options under there.

But my workstation has been set up with Ubuntu. Luckily LibreOffice Writer can do this very easily. I found this easier to achieve in LibreOffice Writer than MS Word. Word kept giving me weird VB Macro errors and it would not let me easily position form controls. Writer lets me easily position controls and assign labels. Writer also lets you control how these form controls are anchored.

To start working with form elements in Writer and Calc:

  • Click View
  • Click Toolbars
  • Select Form Controls
  • Then in the new toolbar:

    • To start editing forms you will need to click the Design Mode

      • You can unclick this option to see what the form looks like

When you are ready to convert the document to a PDF simply click the icon that looks like the Adobe Icon. This is the Export Directly as PDF icon.

To edit things like font and background colour double click the new element. Alternatively, you can also right-click a form control and choose Control Properties....

Annoyances

In Libre Writer each element you add defaults with a black background and the default Writer font (Fira Sands). This is easy to get around by getting one correct and then copy-pasting for any new elements you need.

I also found it infuriating how some elements keep moving between saves. There does not seem to be any way to get this to stop. Perhaps placing elements in a table with invisible borders could be one way to work around this. One thing that seemed to tame this behaviour a bit was using labels instead of normal text. This was especially effective at getting text boxes to align well with labels.

Tips and Tricks

Label Controls vs Text

There is no need to add labels to the form. This becomes tedious as you can only edit the text of a label by double-clicking it.

Instead, simply use normal none-form text and place other form elements like inputs next to the text that it is associated with.

The main situation a label is useful is when your form controls keep moving when you save the file, close it and open it again. Form labels seem to get the form controls to better anchor in their position.

None Standard Elements

Table

This does not seem to be possible. For some elements, a workaround is to insert them into the cells of the table. For example for a checkbox insert a checkbox with no label.

Using the above workaround for text does not work as you cannot make the text box size match that of the cells.

What did work fairly well for me was gluing together input controls. The header of the table was read-only bold text. I then copied one of these “cells” and pasted.

For the none header rows I modified a header cell to not be read-only, took out the default text and adjusted the text size smaller and made the text regular. I also set the text to be wrap instead of inline so that text is not cut off and goes to the next line in the cell. Adjust the alignment to whatever makes sense to you. In my case left aligned and vertical-align top worked the best. I then copied this cell n - 1 times to match the number of columns. Finally, I copy and pasted this row as many times as I needed rows.

There are a few caveats with this approach:

  • Resizing any cells means redoing the entire table. Cells need to be uniform width and height
  • The cells are flush to horizontal cells but there is a small gap between rows

Text Area

There is no text area form control. By this I mean the equivalent of an HTML text area - a text input that can accept text downwards and across, i.e. multiline text input.

This is easy to get around by stretching a text input control long and wide enough. You then need to adjust its properties to horizontal align left, vertical-align top and text wrap instead of inline. Be sure to also make the font size appropriately small enough otherwise it will get cut off when it is input. Make sure you change the font to something like Arial or Times New Roman which are both available on 97% of devices.

Gotchas

Date, Number and Other Form Elements

These elements are not available in the MS Word form builder and they do not appear to be valid form elements for PDFs either. The safest is to stick to these elements:

  • label
  • text
  • checkbox
  • (custom) table (mentioned above)
  • (custom) text area (mentioned above)

Not Always WYSIWYG

I found that what I saw in Writer did not always come out that way in the PDF. Labels for checkboxes, for example, were often cut off despite not being that way in Writer. As a result of this minor quirk, you would need to validate your PDF outputs correctly.

I would also recommend looking at these PDFs in Adobe as I found they rendered fine in Linux but there were a few fields on Adobe on Windows that were cut off slightly.

Fonts Not Rendering on Windows

When I used Adobe Reader on Windows to try fill in the form fields I kept getting what looked like those little dots for password fields.

I confirmed none of these fields was password fields. I then realized what the issue was: the default font used (Fira Sans) is not available in Windows. I do not think it will be available anywhere else either other than Linux.

Ubuntu does not come with the standard Windows fonts like Arial and Times New Roman I believe because they are proprietary.

Installing MS fonts like Times New Roman and Arial is fairly easy. Simply run:

sudo apt install ttf-mscorefonts-installer

Accept the Ts and Cs and you are good to go.

It is also advisable to use a font common to the vast majority of devices. There are 2 types of fonts:

  • San serif: These fonts tend to have more rounded glyphs
  • Serif: These fonts tend to have more angular glyphs

The most widely supported versions for these are:

  • San serif: Arial
  • Serif: Times New Roman

To see how widely supported the font you want to use is have a look at this site.

Conclusion

While on the outset it would not seem like you would be able to easily create fillable PDFs on Linux/Ubuntu, it is easier than on Windows. I would however strongly recommend checking your PDF on Windows just to ensure things like fonts were not missed.