Google apps script Google docs setHeadingAttributes()工作不正常
我正在尝试使用setHeadingAttributes()函数更改Google文档的标题Google apps script Google docs setHeadingAttributes()工作不正常,google-apps-script,google-docs,Google Apps Script,Google Docs,我正在尝试使用setHeadingAttributes()函数更改Google文档的标题 function setHeadings() { var doc = DocumentApp.getActiveDocument(); var body = doc.getBody(); var myNormal_Style = {}; myNormal_Style[DocumentApp.Attribute.FONT_FAMILY] = 'PT Serif'; myNormal_
function setHeadings() {
var doc = DocumentApp.getActiveDocument();
var body = doc.getBody();
var myNormal_Style = {};
myNormal_Style[DocumentApp.Attribute.FONT_FAMILY] = 'PT Serif';
myNormal_Style[DocumentApp.Attribute.FONT_SIZE] = 12;
body.setHeadingAttributes(DocumentApp.ParagraphHeading.NORMAL, myNormal_Style);
var myTitle_Style = {};
myTitle_Style[DocumentApp.Attribute.FONT_FAMILY] = 'Montserrat';
myTitle_Style[DocumentApp.Attribute.FONT_SIZE] = 14;
myTitle_Style[DocumentApp.Attribute.BOLD] = false;
body.setHeadingAttributes(DocumentApp.ParagraphHeading.TITLE, myTitle_Style);
var myHeading1_Style = {};
myHeading1_Style[DocumentApp.Attribute.FONT_FAMILY] = 'Courier New';
myHeading1_Style[DocumentApp.Attribute.FONT_SIZE] = 14;
myHeading1_Style[DocumentApp.Attribute.BOLD] = true;
body.setHeadingAttributes(DocumentApp.ParagraphHeading.HEADING1, myHeading1_Style);
Logger.log(body.getHeadingAttributes(DocumentApp.ParagraphHeading.TITLE));
Logger.log(body.getHeadingAttributes(DocumentApp.ParagraphHeading.HEADING1));
Logger.log(body.getHeadingAttributes(DocumentApp.ParagraphHeading.NORMAL));
}
问题是只有设置正常航向才能正常工作。事实上,普通标题似乎完全覆盖了TITLE和HEADING1,因此它们现在都是PT衬线字体。(将其更改为另一种字体而不是PT衬线会相应地更改所有内容)
检查日志表明一切正常,但包含此脚本的实际文档显示情况并非如此。我试着对设置正常部分进行了注释,结果表明,设置标题或标题1实际上除了在日志中之外什么都不做。我制作了新文档,甚至使用了其他谷歌账户,但他们似乎都有这个问题
从给出的示例中复制和粘贴,这应该是有效的,只会证实我的问题,这似乎与中的相同。我似乎在代码中找不到问题。非常感谢你的帮助 这是一个已经提交的错误:
您可以开始增加可见性
同时,您可以使用一种变通方法手动循环浏览所有段落,并将不同的属性应用于不同的标题,例如“已完成”。这是一个已经在以下方面提出的错误:
您可以开始增加可见性
同时,您可以使用一种变通方法手动循环浏览所有段落,并将不同的属性应用于不同的标题,例如“完成”