搜尋此網誌

2017年6月22日 星期四

Acrobat PDF表單製作javascript學習筆記


Acrobat DC SDK Documentation 文件中有欄位屬性及例子(Field properties)

有關PDF Form問題之討論區 官方討論區

Acrobat Library 有很好的javascript教學 & 範例

Creating a referenced text field in a form


Dynamically setting a submit by e-mail address using Acrobat X and XI 在編輯的檔案中click一個button即將此pdf內容attachment至outlook發出,有例子可download


Lets say I have Buttons A and B and text field "Text1" I need code so when I press button A it change fill color of text field to(example green) and when i press button B it change text field to green also but if it is already green(because of button A) then change color to (example red).Can you Guys help pls?
You can use this code:
var field1 = this.getField("Text1");  
if (color.equal(field1.fillColor, color.green)==true) field1.fillColor = color.red;  
else field1.fillColor = color.green; 

判斷A欄位值的不同而後自動填入B欄(自動填入B欄位的值,需判斷A欄位值的不同而不同)
Basically If Field A is ProductA  Field B=10
If Field A is ProductB then Field B =15
If Field A is ProductC then Field B = 20
You can use this code as the custom calculation script for "Field B":
=========
var fieldA = this.getField("Field A").valueAsString;
if (fieldA=="ProductA") event.value = 10;
else if (fieldA=="ProductB") event.value = 15;
else if (fieldA=="ProductC") event.value = 20;
else event.value = "";

檢查必填欄位
var emptyFields = [];
for (var i=0; i     var f= this.getField(this.getNthFieldName(i));
     if (f.type!="button" && f.required ) {
          if (f.valueAsString==f.defaultValue)
               emptyFields.push(f.name);
     }
}
if (emptyFields.length>0) {
     app.alert("Error! You must fill in the following fields:\n" + emptyFields.join("\n"));
}



Acrobat官方手冊

沒有留言:

張貼留言