javascript - PDF JavaScript:将变量值插入表单字段
问题描述
我有一个带有 JavaScipt 的 PDF,所有最终用户都运行 Adobe Acrobat Pro DC。我已经成功地弄清楚如何让它用其他表单字段的值填充表单字段:
// Assuming FormFieldB has a value of "somewhere" and FormFieldA is a text box
this.getField("FormFieldA").value = "Fills a sentence and adds a string from " + this.getField("FormFieldB").value + " successfully.";
// This fills the box with "Fills a sentence and adds a string from somewhere successfully.
但是我想做的基本上是一样的,但我试图获取一个变量的值并将其添加到表单字段中。
var my_variable = "somewhere";
this.getField("FormFieldA").value = "Fills a sentence and adds a string from <How do I insert from my_variable> successfully";
// I want it do write the same example sentence as before
有任何想法吗?谢谢!
解决方案
只需连接字符串...
var my_variable = "somewhere";
this.getField("FormFieldA").value = "Fills a sentence and adds a string from "+my_variable+" successfully";
推荐阅读
- debugging - Windows 10 IoT Core ARM64 AppServiceConnection 用于后台应用程序调试
- android - APK逆向工程Firebase信息读取问题?
- python - Django 站点地图错误:“datetime.time”对象没有属性“timetuple”
- dictionary - 如何清除sync.Map
- python-3.x - 从字典列表中获取组合的数据框
- r - 错误代码:函数 {x} 中的错误:尝试将变量绑定到 R_UnboundValue
- c++ - 字符串数组长度 C++ 问题?
- java - 如何使用@Inject?
- javascript - 字符串替换不适用于 for ... of 迭代
- python - while 循环需要特定的顺序才能工作?