fillable PDF form

Dear community,

Hopefully an interesting question: is it possible to create a fillable PDF form using R markdown?

We can create all sorts of PDF files using markdown, but I never saw an interactive form containing text boxes, radio buttons or checkboxes.

Thanks in advance for any hint,
Adrian

If you are rendering to pdf, you can take advantage of tex features. Here's a short example using text inputs (\TextField) and checkboxes (\CheckBox). I defined a few options (width, border color) as an example, but there are plenty of other options available (i.e., layouts, heights, etc.). It would be better to wrap this in a new command.

I should note that I am using the full MacTex 2020 distribution and running on R 3.6.3. Depending on your LaTeX setup, you may need to install additional packages.

---
title: "Example Form"
output: pdf_document
header_inclues:
- \parskip = 2pt
---

## Form

Enter your name and select one or more options.

\begin{Form}
\TextField[width=15em, bordercolor={0 0 0}]{Enter your name:} \par
\CheckBox[name=optionA, width=10pt, bordercolor={0 0 0}]{Option A} \par
\CheckBox[name=optionB, width=10pt, bordercolor={0 0 0}]{Option B} \par
\CheckBox[name=optionC, width=10pt, bordercolor={0 0 0}]{Option C} \par
\CheckBox[name=optionD, width=10pt, bordercolor={0 0 0}]{Option D} \par
\CheckBox[name=optionE, width=10pt, bordercolor={0 0 0}]{Option E} \par
\end{Form}

This will render the following document.

example_form

1 Like

Oh, I see...
I was not aware one can create forms in LaTeX, but now that you mention it of course it is possible! Shame on me for not thinking about this.
Excellent stuff, thanks very much!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.