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

时间:2015-10-21 21:21:45

标签: r pdf markdown

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

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

我的问题:

  

是否可以在PDF表单中创建可填写的文本框?

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

1 个答案:

答案 0 :(得分:7)

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查看器。