簡體   English   中英

Indesign中的Basil.js和ExtendScript /如何設置textFrames的樣式?

[英]Basil.js and ExtendScript in Indesign / How can I style textFrames?

在Indesign中放置/繪制svg元素后,我想更改部分或全部元素的樣式。 在我的示例中,我在繪制textFrame時設置了樣式。 我的例子有效。

但是在放置textFrame 之后如何更改樣式?

我想使用偏斜角(應用於TextFrame)和rotationAngle(在我的示例中-> forLoop)

我嘗試了以下方法: r.textFrames.shearAngle=20; doc.textFrames.add({shearAngle:20}); ...但是兩者都不起作用。

    #includepath "~/Documents/;%USERPROFILE%Documents";
    #include "basiljs/bundle/basil.js";

    // this script shows how to load data into 
    // basil for further usage. 
    // The document you are working with needs to be saved at least once. 
    // The data needs to be in a folder next to that document 
    // The folder needs to be named "data" 
    // take a look into the output of the JS console of the ESTK
    function draw() {
      var doc = b.doc();
      b.clear(doc); // clear the doc
      b.units(b.MM); // use MM
      var yTextFrame = 195;
      // get the scripts name// get its containing folder// get the name of the script without the extension // add the .indd to the extension
      var fname = File($.fileName).parent.fsName + '/' + ($.fileName.split('/')[$.fileName.split('/').length - 1]).split('.')[0] + '.indd';
      // and save it
      doc.save(fname, false, 'basil', true); //save the file next to the script

      // code goes here -----------
      var filecontent = b.loadString("data.json"); // load the text file
      b.println(filecontent.constructor.name); // take a look at what kind of content we have
      var json = b.JSON.decode(filecontent); // transform it to JSON
      b.println(json.constructor.name); // take a look again what json is
      b.println(json.description); // print something from the file
      // loop all the entries
      for (var i = 0; i < 5; i++) {
        b.println(json.laundry_care_instructions[i].instruction); // take a look at the entry
        b.println(json.laundry_care_instructions[i].instruction.length); // how many characters does the entry have
        var r =b.text(json.laundry_care_instructions[i].instruction, 10 + 7 * i, yTextFrame, b.width - 20, 7).properties={rotationAngle:90, shearAngle:20};// create a text box with the entry // // The skewing angle applied to the TextFrame 
      }
      // end of your code ---------

    }
    b.go();

你差點知道了。 在您的代碼中,變量r已經是一個textFrame對象。

因此應該是:

r.shearAngle = 20; 

明天上課見;-)

編輯1:

如評論中所述。 編碼

var r = b.text("txt",x,y,width, height).properties = {something:10};

返回properties對象。 不是TextFrame。 刪除.properties部分和Benedikts,我的方法應該可以正常工作。

編輯2:

Benedikts方法不起作用。 我收到以下錯誤。

Error: Object does not support the property or method 'shearAngle'

@Benedikt:shearAngle不是文本屬性。 它適用於諸如TextFrame,Rectangle,Oval等的pageItem。 Basil.js中是否可以設置此類屬性? 以及嵌套屬性如何? 我將為此設置一個新問題

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM