0

I want to set the textbox autofix as shrink to shape,

I dont understand how to set the autofit for existing as SHRINK text on overflow

enter image description here I have tried with

  Slides.Presentations.Pages[0].get(presentationId, pageObjectId).pageElements[3].shape.shapeProperties.autofit
2

1 Answer 1

1

You are trying to set the properties of a shape by using a GET request.

If you check the documentation page of the request:

GET https://slides.googleapis.com/v1/presentations/{presentationId}/pages/{pageObjectId}

Gets the latest version of the specified page in the presentation.

Moreover, the fields you are using are also wrong. Pages is part of the request and you cannot pass any parameters to it and pageObjectId is in fact the id of the page, not the id of the object you are trying to modify.

In order to set the update the shape properties of an object, you will have to make the following request:

POST https://slides.googleapis.com/v1/presentations/{presentationId}:batchUpdate

And use the following body:

{
  "requests": [
    {
      "updateShapeProperties": {
        "objectId": "OBJECT_ID",
        "shapeProperties": {
          "autofit": {
            "autofitType": "AUTOFIT_TYPE"
          }
        },
        "fields": "autofit.autofitType"
      }
    }
  ]
}

However, it is important to note the following as it might be the reason you are receiving the Autofit types other than NONE are not supported error:

The field is automatically set to NONE if a request is made that might affect text fitting within its bounding text box. In this case the fontScale is applied to the fontSize and the lineSpacingReduction is applied to the lineSpacing. Both properties are also reset to default values.

This concern has already been raised on Google's Issue Tracker here and you can see that this indeed the intended behavior in this situation. What you can do instead is to file a feature request by using the form here and provide all the necessary details.

Reference

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.