英文:
How to remove highlight in the google slides API?
问题
我正在使用Google API Python客户端来替换文本占位符为生成的数据。在这个示例中,我检测到所有实例的"bar"并将它们替换为"foo",在所有幻灯片中。slides_service
是通过apiclient.discovery.build(...)
进行实例化的。
如果"bar"具有高亮颜色,当我用"foo"替换它时,如何去除高亮颜色呢?我认为我需要向批量请求数组中添加一个单独的请求,但是我一直在这里上下滚动,没有找到任何线索。
为了更清晰,这是我所说的高亮选项,正如它在UI中呈现的那样。
英文:
I am using the Google API Python Client to replace text placeholders with generated data. In this example, I detect all instances of "bar" and replace them with "foo", in all slides. slides_service
is instantiated with apiclient.discovery.build(...)
batch_requests_array = [
{
"replaceAllText": {
"replaceText": "foo",
"containsText": {
"text": "bar",
"matchCase": False
}
}
}
]
batch_requests = {"requests": batch_requests_array}
request = slides_service.presentations().batchUpdate(presentationId=slides_id, body=batch_requests)
res = request.execute()
Now if bar has a highlight color, how can I remove that when I replace it with foo? I think I need to add a separate request to my batch requests array, but I have been scrolling up and down here without finding any clue.
For clarity, this is the highlight option I am talking about as it's presented in the UI
答案1
得分: 1
要移除文本的突出显示颜色,您需要更新backgroundColor
。为了给您一个想法,以下是请求的外观,这将使背景完全透明:
highlightedTextRequest = [
{
"updateTextStyle": {
"objectId": "objectId",
"style": {
"backgroundColor": {
}
}
}
}
]
注意: 请求中的objectId
是要样式化文本的形状或表格的ID。
参考文献:
英文:
To remove the highlight color of a text, you will have to update the backgroundColor
. To give you an idea, this is how the request should look, this will set the background fully transparent:
highlightedTextRequest = [
{
"updateTextStyle": {
"objectId": "objectId",
"style": {
"backgroundColor": {
}
},
"fields": "*"
}
}
]
Note: The objectId
in the request, is the ID of the shape or table with the text to be styled.
References:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论