Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create Fillable PDF Textbox via R

Tags:

markdown

r

pdf

I am using the test file from R Markdown, generated in RStudio by simple creating a new markdown file. It appears as follows:

---
title: "Fillable Textbox?"
author: "The Need To Edit"
date: "Wednesday, October 21, 2015"
output: pdf_document
---

  This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

```{r}
summary(cars)
```

You can also embed plots, for example:

```{r, echo=FALSE}
plot(cars)
```

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.

My Question:

Is it possible to create a fillable textbox within the PDF form?

I am working to automate some of my workflow however within that automation the end user may need to add comments. I thought a fillable textbox would be a nice way to maintain a standard document format and give my users some freedom. I have found ways to do nearly everything except add a fillable textbox, perhaps I am searching the wrong expression?

like image 761
Badger Avatar asked Oct 21 '15 21:10

Badger


People also ask

Can you make a PDF fillable?

In Adobe Acrobat you can make a PDF fillable form from scratch, convert PDF files from a Microsoft Word document, or even upload a smartphone image or a scanned paper document.

How do I create a PDF in R studio?

Having saved your R Markdown file, it's time to process it and generate a PDF file. You can do this by clicking the Knit PDF button above the text. Your PDF file will be generated and opened as shown below.


1 Answers

The hyperref package (which is loaded automatically) allows fillable fields. It is just a matter of use its specific commands, which you can find here. Try this code (click on the right of the word Name).

---
title: "Fillable Textbox?"
author: "The Need To Edit"
date: "Wednesday, October 21, 2015"
output: pdf_document
---

Since Rmarkdown uses knitr and it loads automatically hyperref I think hat this should work.

In fact it is just a matter of use some \LaTeX\ commands of the hyperref package.

```{r, echo=FALSE}
plot(cars)
```


\begin{Form}
    \TextField{Name}
\end{Form}

Of course this PDF is fillable as a PDF, and then it will not work inside the RStudio (if you use it) PDF viewer.

like image 119
SabDeM Avatar answered Sep 23 '22 13:09

SabDeM