通过 R 创建可填写的 PDF 文本框

Create Fillable PDF Textbox via R

我正在使用 R Markdown 中的测试文件,它是在 RStudio 中通过简单地创建一个新的 markdown 文件生成的。显示如下:

---
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.

我的问题:

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

我正在努力使我的一些工作流程自动化,但是在该自动化中,最终用户可能需要添加评论。我认为可填写的文本框将是维护标准文档格式并为我的用户提供一些自由的好方法。除了添加可填写的文本框外,我已经找到了几乎所有的方法,也许我正在搜索错误的表达式?

hyperref 包(自动加载)允许填写字段。这只是使用其特定命令的问题,您可以找到 here。试试这个代码(点击单词右边的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}

当然这个 PDF 可以作为 PDF 填写,然后它就不能在 RStudio(如果你使用它)PDF 查看器中工作。