How to write a text file in Acrobat Javascript

后端 未结 3 547
被撕碎了的回忆
被撕碎了的回忆 2021-02-04 13:22

I am using acrobat XI I have tried output a text file like this

var cMyC = \"abc\";
var doc = this.createDataObject({cName: \"test.txt\", cValue: cMyC});
this.e         


        
3条回答
  •  借酒劲吻你
    2021-02-04 13:42

    Here's a way to output to a fixed path text file using doc.exportAsText:

    // set up output text
    var TEMP_FIELD_NAME = "testHeader"
    var textValue = "test";
    // add a temporary text field
    var f = this.addField(TEMP_FIELD_NAME, "text", 0, [30,30,100,20]);
    f.value = textValue;
    // export field name and value to defined file
    this.exportAsText({aFields: TEMP_FIELD_NAME, cPath: "test-text.txt"});
    // remove text field
    this.removeField(TEMP_FIELD_NAME);
    

    The resulting text file will have two lines:

    testHeader

    test

提交回复
热议问题