Google apps script 缩进谷歌文档中的段落-谷歌应用程序脚本
我正试图用谷歌应用程序脚本缩进一个段落——只是一个普通的缩进。这应该是世界上最简单的事情,但事实证明这非常令人沮丧 下面是我调用的代码的相关部分,请记住我所做的所有其他操作(下划线、粗体设置等)都非常有效Google apps script 缩进谷歌文档中的段落-谷歌应用程序脚本,google-apps-script,formatting,google-docs,paragraph,Google Apps Script,Formatting,Google Docs,Paragraph,我正试图用谷歌应用程序脚本缩进一个段落——只是一个普通的缩进。这应该是世界上最简单的事情,但事实证明这非常令人沮丧 下面是我调用的代码的相关部分,请记住我所做的所有其他操作(下划线、粗体设置等)都非常有效 function AppendDocument(){ var doc = DocumentApp.openById('____________________'); var body = doc.getBody(); var myParagraph = body.app
function AppendDocument(){
var doc = DocumentApp.openById('____________________');
var body = doc.getBody();
var myParagraph = body.appendParagraph("Hello This is a paragraph - I want to indent this please");
myParagraph.setUnderline(true); //<-- Things like this work fine
myParagraph.setIndentStart(72.0); //I just randomly chose 72. No number is working.
}
函数AppendDocument(){
var doc=DocumentApp.openById('uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu');
var body=doc.getBody();
var myparagration=body.appendparagration(“您好,这是一个段落,我想把它缩进”);
myparagration.setUnderline(true);//您需要定义所有缩进参数:
myParagraph.setIndentFirstLine(72);
myParagraph.setIndentStart(72);
myParagraph.setIndentEnd(72*2);
请记住,您要传递的参数是在排版点。请参见下面我为什么使用72作为基数
如果单击此处的标识选项:
您将看到缩进选项是如何通过UI定义的:
然后,您可以了解如何在Google Apps脚本中定义缩进长度。您只需正确进行转换。在UI中,您可以使用英寸定义缩进长度。为了找到印刷点和英寸之间的精确转换,您可以:
1 inch (UI) = 72 typographic points (Google Apps Script)