Reputation: 669
I need to retrieve the page object id of a slide in Google slides based on text located in the slide. I was wondering if there was a way to do this using google slide API for python.
Upvotes: 1
Views: 4038
Reputation: 1566
This short code should explain how to extract all relevant information from all the slides including slide objectid.
function logSlidesObjectIdAndElements() {
var presentationId = 'ACTUAL_ID';
var presentation = Slides.Presentations.get(presentationId);
var slides = presentation.slides;
Logger.log('The presentation contains %s slides:', slides.length);
for (i = 0; i < slides.length; i++) {
Logger.log(
'- Slide with objectid:%s Slide#%s contains %s
elements.',slides[i].objectId,i + 1,
slides[i].pageElements.length);
}
}
Upvotes: 1
Reputation: 6737
I am not sure if there is an existing implementation. I can see in the documentation that you need to get the objectID
by supplying the needed presentationID
and not the "content"
.
For example in the Try it
section of the Method: presentations.get, you need to supply the presentationID before you can achieve the response containing your needed information like "objectId"
and "content"
.
{
"presentationId": "000AAAAAAAAA_AAA0AA00AA00A0A0AAAA00AAAA7AAA",
"pageSize": {
"width": {
"magnitude": 9144000,
"unit": "EMU"
},
"height": {
"magnitude": 5143500,
"unit": "EMU"
}
},
"slides": [
{
"objectId": "p",
"pageElements": [
{
"objectId": "i0",
"size": {
"width": {
"magnitude": 3000000,
"unit": "EMU"
},
"height": {
"magnitude": 3000000,
"unit": "EMU"
}
},
"transform": {
"scaleX": 2.8402,
"scaleY": 0.6842,
"translateX": 311708.35000000003,
"translateY": 744575,
"unit": "EMU"
},
"shape": {
"shapeType": "TEXT_BOX",
"text": {
"textElements": [
{
"endIndex": 6,
"paragraphMarker": {
"style": {
"direction": "LEFT_TO_RIGHT"
}
}
},
{
"endIndex": 6,
"textRun": {
"content": "My ID\n",
"style": {}
}
}
]
},
Upvotes: 0