Word.ShapeScaleFrom enum

指定在缩放形状时,该形状的哪一部分将保持在原有的位置。

注解

[ API 集:WordApiDesktop 1.2 ]

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/group-ungroup.yaml

await Word.run(async (context) => {
  // Scales the first set of grouped shapes (including text boxes) found in the document body.
  const firstShapeGroup: Word.Shape = context.document.body.shapes
    .getByTypes([Word.ShapeType.group])
    .getFirstOrNullObject();
  firstShapeGroup.load("shapeGroup/shapes");
  await context.sync();

  if (firstShapeGroup.isNullObject) {
    console.log("No shape groups found in the document body.");
    return;
  }

  let shapeGroup: Word.ShapeGroup = firstShapeGroup.shapeGroup;
  console.log("About to scale the first shape group found in the document body:", shapeGroup.shapes);
  firstShapeGroup.scaleHeight(0.75, Word.ShapeScaleType.currentSize);
  firstShapeGroup.scaleWidth(0.5, Word.ShapeScaleType.currentSize, Word.ShapeScaleFrom.scaleFromBottomRight);

  console.log("Scaled the first shape group.");
});

字段

scaleFromBottomRight = "ScaleFromBottomRight"

从形状的右下角缩放。

scaleFromMiddle = "ScaleFromMiddle"

从形状中心缩放。

scaleFromTopLeft = "ScaleFromTopLeft"

从形状左上角缩放。