2

Is it possible to set Element Shape background color with Hexadecimal format eg #B6D7A8 ? I see an example here, Google Slides API- How to change text color for all shapes of a certain color

However, the Google Slide API reference does not mention it. I want to be sure, and specifically for Java environment.

https://developers.google.com/slides/reference/rest/v1/presentations.pages/other#Page.OpaqueColor

    requests.add(new Request()
            .setUpdateShapeProperties(new UpdateShapePropertiesRequest()
                .setObjectId(elementRandomString)
                    .setShapeProperties(new ShapeProperties()
                            .setShapeBackgroundFill(new ShapeBackgroundFill()
                                .setSolidFill(new SolidFill()
                                        .setColor(new Col)

enter image description here

mattsmith5
  • 540
  • 4
  • 29
  • 67
  • if there is community interested in doing this, can someone open up a Google Issues tracker here? I feel reluctant to do so, since I've already opened up 2 in last week, if there is community interest feel free to do so, thanks https://issuetracker.google.com/u/2/issues?q=componentid:191598%20status:open – mattsmith5 Mar 25 '21 at 15:25

1 Answers1

1

The answer provided in the post Google Slides API- How to change text color for all shapes of a certain color uses Slide Service in Apps Script to set the color.

To answer your question, it is not possible to set the color in HEX format. As mentioned in the reference document that you provided, You need to provide an RgbColor object in your OpaqueColor.

Workaround:

  1. Convert your hex color to RGB then divide red, blue and green value by 255 to obtain the RgbColor accepted value which is 0.0 ~ 1.0

You might want to consider this as reference: java : convert Hex color #RRGGBB to rgb r g b?

  1. Set RgbColor based on your converted red, blue and green value.

Sample Code:

requests.add(new Request()
            .setUpdateShapeProperties(new UpdateShapePropertiesRequest()
                .setObjectId(elementRandomString)
                    .setShapeProperties(new ShapeProperties()
                            .setShapeBackgroundFill(new ShapeBackgroundFill()
                                .setSolidFill(new SolidFill()
                                        .setColor(new Color()
                                                .setRgbColor(new RgbColor()
                                                      .setRed(redFloatValue)
                                                      .setBlue(blueFloatValue)
                                                      .setGreen(greenFloatValue))))))));

References:

Ron M
  • 5,791
  • 1
  • 4
  • 16
  • By the way, I was not able to reproduce your concern due to lack of environment platform. Please let me know if there is an issue with the sample code provided Thanks – Ron M Mar 25 '21 at 15:38
  • ok, thanks, I am familiar with RGB as mentioned in question resource, I will just use that then, by the way, can you have someone update this feature request? https://stackoverflow.com/questions/66715704/google-slides-api-increase-page-size-in-create-presentation its been reported as a bug, people are aware of stack, maybe they forgot about it, I am not sure, thanks https://issuetracker.google.com/issues/119321089 – mattsmith5 Mar 25 '21 at 17:35
  • I'm sorry about that but I don't have enough permissions to seek for an update regarding the issues/features submitted – Ron M Mar 25 '21 at 17:38
  • hi, just placed another question here, https://stackoverflow.com/questions/66863716/google-slides-rotate-rectangle-35-degrees – mattsmith5 Mar 30 '21 at 01:57
  • Hi I'm sorry, due to our guidelines changes it is not possible for me to support cases created outside my shift. Rest assured your posted question can be supported by someone within our team – Ron M Mar 30 '21 at 15:09