Google UI App Scripts: Create a Google Doc with a

2020-07-18 20:13发布

Using Google UI App Scripts how can you create a new Google Doc with a legal paper size and landscape layout? From the Document Service page I see how you can create a new document and edit a lot of the elements but not the page size or layout orientation. Am I missing it? Or is this something that is not possible?

1条回答
闹够了就滚
2楼-- · 2020-07-18 20:46

Paper size of the document can be set using setPageHeight and setPageWidth methods of the class Body

  function setPageSize(){
    var doc = DocumentApp.create("file name");
    var body = doc.getBody();
    var pointsInInch = 72;
    body.setPageHeight(6.5 * pointsInInch);  //6.5 - inches
    body.setPageWidth(4 * pointsInInch); // 4 - inches
  }
查看更多
登录 后发表回答