有没有办法使用应用程序脚本将 Google 文档页面布局设置为横向。
我有一个脚本可以将 Google 电子表格复制到 Google 文档,但它太宽而无法正确显示。如果我可以将布局更改为横向,它将正确显示。
无论页面是纵向还是横向,页面宽度似乎都是相同的数字。
另一个问题是,如果我将 body.setPageWidth(792).setPageHeight(612) 用于字母,它会更改页面宽度和高度,但不会更改为横向。
我相信您的目标如下。
遗憾的是,现阶段文档服务(DocumentApp)似乎还无法实现这一点。但幸运的是,当使用 Google Docs API 时,这是可以实现的。在这种情况下,下面的示例脚本怎么样?
在使用此脚本之前,请在高级 Google 服务中启用 Google Docs API。
function myFunction() {
const docId = DocumentApp.create("sampleFilename").getId(); // or please manually set the document ID.
Docs.Documents.batchUpdate({ requests: [{ updateDocumentStyle: { documentStyle: { flipPageOrientation: true }, fields: "flipPageOrientation" } }] }, docId);
}
flipPageOrientation: true
。flipPageOrientation: false
。