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

9

我正在使用由简单创建新的markdown文件在RStudio生成的R 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.

我的问题:

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

我正在努力自动化我的一些工作流程,但是在这个自动化过程中,最终用户可能需要添加评论。我认为填写文本框是保持标准文档格式并给予用户一些自由的好方法。我已经找到了几乎所有的东西,除了添加一个可填写的文本框,也许我搜索的表达方式不正确?

1个回答

12

hyperref宏包(自动加载)允许填写字段。只需使用其特定命令即可,你可以在这里找到它们(链接)。尝试这段代码(点击单词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文件本身是可填写的,但如果你使用RStudio自带的PDF查看器,它将无法在其中运行。

1
这正是我想要的,谢谢。奇怪的是这份文档在我的搜索中没有出现。不管怎样,这将节省许多时间!干杯。 - Badger
如果这超出了范围,我会提一个新问题(其他人可能也会想知道)。我希望更改文本框的大小,并允许它在超出时扩展。我尝试声明TextField参数并调用\MakeTextField{width}{height},填写英寸单位(也尝试过像素,但没有声明单位),但收到了可爱的状态43。正如我所说,如果离题太远,我很乐意开一个新的主题。 - Badger
嗯,很奇怪。@HoneyDippedBadger 尝试使用Adobe Reader打开,如果还是不行,可以尝试使用这些选项\TextField[width = Xcm, height = Xcm]{Label:},其中X为数字。 - SabDeM
1
非常好,这生成了一个漂亮的大文本框。原来是单元声明,我没有在文档中注意到它,认为R是理所当然的。现在要解密文本换行和文本框扩展!(如果我无法解决这些问题,我会提出新问题)非常感谢您的快速回复! - Badger

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接