突出显示谷歌文档中的单词

时间:2015-11-16 10:23:48

标签: javascript html google-docs google-document-viewer

有没有办法突出显示使用google doc

查看的docx文件中的特定单词

实施例: 我有以下文档,我正在使用谷歌文档查看它,我需要在文档中突出显示“Step”单词和其他颜色

Google Doc Document

除了打开文档,编辑,保存然后将其返回给Google文档查看器之外,是否有任何可用的方法?

1 个答案:

答案 0 :(得分:0)

您可以使用Google Apps Script来创建,访问和修改Google文档文件。

此处的文档example将文本的一半更改为蓝色:

 var body = DocumentApp.getActiveDocument().getBody();

 // Use editAsText to obtain a single text element containing
 // all the characters in the document.
 var text = body.editAsText();

 // Insert text at the beginning of the document.
 text.insertText(0, 'Inserted text.\n');

 // Insert text at the end of the document.
 text.appendText('\nAppended text.');

 // Make the first half of the document blue.
 text.setForegroundColor(0, text.getText().length / 2, '#00FFFF');

要突出显示特定字词,您可以使用findText()

相关问题