2017-09-01 89 views
0

我正在制作一个pdf文件,其中包含许多页面,并在eacb页面上包含人名。我将标签命名为所有字段中的相同内容,以便在整个pdf中轻松自动化名称。PDF在不影响原始输入的情况下切换自动填充字段中的不同值,但不影响原始输入

客户想要的功能更改名称在整个文件,所以现在当我试图更改页面上的名称除了第一(当它问你的名字最初)它改变了所有领域,例如:

Table of what I need accomplished

我想在每场运行简单的JavaScript的:

this.getField("Date") = event.value || event.value = event.value; 

我到了脚本的范围的思考。我正在属性的操作选项卡中工作,所以我真的需要设置变量?所以我做了:

var name000 = this.getField(“Name”); name000 == event.value || event.value == event.value;

然后我浏览了整个文档,并且唯一地更改了所有的字段名称。而不是所有的日期,Name00,Name01,Name02,Name03等等,一直到Name24。

用于最初的几个标签:

this.getField("Date").value = this.getField("Date00").value; 
this.getField("Date").value = this.getField("Date01").value; 
this.getField("Date").value = this.getField("Date02").value; 

这个方案的问题是Date00后字段为空就像我没有做任何事情。因此增加变数,相同情况

this.getField("Name") = event; 
// set value of field "Name" to this field's value; 
this.getField("Name00").value = event.value; 
// end on blur action for field Date; 


var Name1 = this.getField("Name"); 
var Name2 = this.getField("Name01"); 
Name2.value = Name1.value; 
// end on blur action for field Date; 

var Name1 = this.getField("Name"); 
var Name3 = this.getField("Name02"); 
Name3.value = Name1.value; 

Third label is blank, so I assigned unique variables named the Name Field differently and still blank after I assign more than one field. 

var name000 = this.getField("Date"); 
name000 == event.value || event.value == event.value; <-- This has the same problem. 

9/2更新。

this.getField(“Name”)= event.value || event.value = event.value; Onblur Javascript错误“SyntaxError:左侧的赋值无效”。仅仅从这个错误,我不想通过整个表单来纠正所有的字段名称“名称”。我有他们不同的名称: 名称,Name01,Name02,03,10,直到Name24

加上它似乎耗时多哥到各个领域复制:

this.getField("Name") = event.value || event.value = event.value; 
this.getField("Name00") = event.value || event.value = event.value; 
this.getField("Name01") = event.value || event.value = event.value; 
this.getField("Name02") = event.value || event.value = event.value; 
this.getField("Name03") = event.value || event.value = event.value; 
      " \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\" 
this.getField("Name24") = event.value || event.value = event.value; 

不反正计算。

尝试更多的自动化和更少的代码的OOP脚本:

var i f fi nv; 
function n(f){ 
    return n > 9 ? "" + n: "0" + n; 
} 

f = this.getField(“Name") = event.value; 

fi = this.getField("'Name' + i") = event.value; 

nv = event.value = event.value; 

while (i = 0; i < i++) { 
return i <= 24; 
}; 

f fi || nv; 

我得到一个错误,但是,缺少“;”在第2行?

从博客我注意到他们只用第一个字段的脚本来完成任务。我可以通过PDF主Javascript元数据更改所有相同字段的更新吗?有没有人做过这个? 有没有简单的方法或解决这个问题?我在这方面花了太多时间。

+0

我一直对这个挑战我无法弄清楚。我发现这篇博文中有一个来自以前版本Acrobat X的示例,但是JavaScript逻辑在那里.--> https://blogs.uoregon.edu/developments/2010/07/14/use-data-from-一个场到填入-其它场合的,杂技演员-填充在表单/ – Tryah85

回答

0

进一步调查,我发现每个字段必须是唯一的,除主每场需要JavaScript才能在操作选项卡在属性运行的onblur:

//Set the source and destination vars: 
     var source = this.getField("ClientName"); 
     var destination = this.getField("CN2"); 

//See if destination is empty and if so, insert source value 
     if(destination.value==''||destination.value==null){destination.value=source.value} 
相关问题