@csaspose,
You can use Fill.oneColorGradient or Fill.twoColorGradient method to add gradient background to any shape. Please check the following code:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shapeRec = builder.insertShape(ShapeType.RECTANGLE, 400, 200);
shapeRec.getFill().oneColorGradient(GradientStyle.FROM_CENTER, GradientVariant.VARIANT_1, 45);
Shape shapeTri = builder.insertShape(ShapeType.TRIANGLE, 200, 300);
shapeTri.getFill().twoColorGradient(Color.red, Color.white, GradientStyle.VERTICAL, GradientVariant.VARIANT_3);
doc.save("C:\\Temp\\shapesWithGradients.docx");
Please check the API Reference page for more information.