我尝试创建一个演示文稿,将其用作模板。我还需要定义布局的objectID(这样我就可以轻松地创建幻灯片并应用布局)。我可以定义它的唯一方法是创建一个新的演示文稿,其中有自定义的布局和母版。
当我将主键和布局键添加到请求中时,google slides api会忽略它。它将简单轻巧的主题应用到演示文稿中。
我怎么才能修复它?
以下是代码示例(我尝试向幻灯片和布局中添加元素,但结果相同)
body = {
"masters": [
{
"pageType": "MASTER",
"objectId": "Master",
"masterProperties": {
"displayName": "Master Name"
}
}
],
"layouts": [
{
"pageType": "LAYOUT",
"objectId": "Layout",
"layoutProperties": {
"displayName": "Layout Name",
"name": "Layout Name",
"masterObjectId": "Master"
}
}
],
"slides": [
{
"slideProperties": {
"masterObjectId": "Master",
"layoutObjectId": "Layout"
},
"objectId": "Slide"
}
],
"title": "2019-11-12 - Template",
"locale": "en-US"
}
presentation = service.presentations().create(body = body).execute()发布于 2019-11-19 19:28:01
正如您所看到的in the official documentation,方法presentations.create只创建了一个空白表示。只有title和presentationId (如果您提供了它)将被考虑在内。“请求中的其他字段,包括任何提供的内容,将被忽略”。这基本上和你得到with Docs API的行为是一样的。
因此,为了向演示文稿中添加内容、样式、属性等,您必须使用batchUpdate。
我希望这对你有任何帮助。
https://stackoverflow.com/questions/58824017
复制相似问题