Skip to main content

GetPreset

Returns the name of the preset shape if the current geometry is based on a preset.

Syntax

expression.GetPreset();

expression - A variable that represents a ApiGeometry class.

Parameters

This method doesn't have any parameters.

Returns

ShapeType | null

Example

Identify which built-in shape template was used for a shape in a PDF.

// How do I find out what preset shape type is being used in a PDF?

// Check whether a shape is using a preset or a custom design in a PDF.

const doc = Api.GetDocument();
const page = doc.GetPage(0);

let fill = Api.CreateSolidFill(Api.RGB(255, 200, 100));
let stroke = Api.CreateStroke(36000, Api.CreateSolidFill(Api.RGB(200, 100, 0)));
let shape = Api.CreateShape("star5", 100 * 36000, 100 * 36000, fill, stroke);
let geometry = shape.GetGeometry();
shape.GetContent().GetElement(0).AddText("Preset: " + geometry.GetPreset() + ", IsCustom: " + geometry.IsCustom());
shape.SetPosition(1000000, 1000000);
page.AddObject(shape);