How do I move a smart object to the center of the canvas? Why is my setContentsBounds method unavailable?

How do I move a smart object to the center of the canvas? Why is my setContentsBounds method unavailable? String tempPsdPath = “temp_output.psd”;
SmartObjectLayer smartObjectLayerNewImg = new SmartObjectLayer(stream);
// smartObjectLayerNewImg.resize(canvasWidth,canvasHeight);
Rectangle bounds = smartObjectLayerNewImg.getBounds();
smartObjectLayerNewImg.setContentsBounds(new Rectangle(200, 200, canvasWidth, canvasHeight));
smartObjectLayerNewImg.updateModifiedContent();

        Layer[] layers1 = newPsd.getLayers();
        layers1 = ArrayUtils.add(layers1,smartObjectLayerNewImg);
        newPsd.setLayers(layers1);
        newPsd.save(tempPsdPath);

@houdajin please check the documentation pages: Smart Object Update and Export using Aspose.PSD for Java|Documentation

Also, please check my previous answers:

Also, if you need support on a priority basis, along with the direct access to our Paid Support management team, plesse check Aspose Paid Support Services. Dedicated team can help you with the any tasks.

Also, please check https://consulting.aspose.com/. Aspose provides great paid support services.

Thank you very much for your reply

1 Like