想要在Acrobat中使用javascript来保存到我的代码生成的文件名

时间:2017-09-20 17:05:27

标签: javascript save acrobat

我可以使用app.execMenuItem(“SaveAs”)并写入我要保存的文件名。但我宁愿它在代码中生成一个文件名。

var pp = this.getPrintParams();
pp.interactive = pp.constants.interactionLevel.full;
pp.printContent = pp.constants.printContents.doc;
var place = this.getField("Locations").valueAsString;
var userID = this.getField("Username").valueAsString;
var pType = this.getField("formType").valueAsString;
var fileName = "iii-"+pType+"-memo_sierra-"+userID+".pdf";
if (place == "dt" || place == "cl") {
 this.flattenPages(0,0,2); 
 this.deletePages(1);
} else if (place == "la") {
  // Law print Memo only
  this.print(false,0,0);
} else {
  // Anderson so print Memo and Agreement
 this.print(pp);
}
//app.execMenuItem("SaveAs");
this.saveAs(this.fileName);

1 个答案:

答案 0 :(得分:0)

最后一行应该是......

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<div class="auction_box"></div>

<script>
var result = 'ok';
if (result == 'ok') {
    $('.auction_box').animate({
        'backgroundColor': '#A3D1A3'
    }, 500);
    setTimeout(
    function (data) {
        $('.auction_box').css('background-color', '#000');
    },5000);
}
</script>

但是,“saveAs”方法只能在批处理或控制台事件期间或在特权上下文中执行。