PowerPoint.PictureAddOptions interface

注意

此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。

表示添加 由 PowerPoint.Shape 对象) 表示的图片 (时可用的选项。

注解

API 集:PowerPointApi BETA (仅预览版)

使用方

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/preview-apis/add-picture.yaml

// Insert a picture on the current slide.
await PowerPoint.run(async (context) => {
  const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0);

  // Use PictureAddOptions to control the position and dimensions (in points).
  const options: PowerPoint.PictureAddOptions = {
    left: 100,
    top: 100,
    width: 250,
    height: 180,
  };

  const picture: PowerPoint.Shape = slide.shapes.addPicture(getSampleImageBase64(), options);
  picture.name = "SamplePicture";

  // Set accessibility properties on the inserted picture.
  picture.altTextTitle = "Sample image";
  picture.altTextDescription = "A cartoon dog image used as a sample picture in this add-in.";

  await context.sync();
});

属性

height

指定图片的高度(以磅为单位)。 如果未提供,则默认值为 72 磅 (1 英寸) 。 InvalidArgument使用负值设置时引发异常。

left

指定从图片左侧到幻灯片左侧的距离(以磅为单位)。 如果未提供,则默认值为 0。

top

指定从图片上边缘到幻灯片上边缘的距离(以磅为单位)。 如果未提供,则默认值为 0。

width

指定图片的宽度(以磅为单位)。 如果未提供,则默认值为 72 磅 (1 英寸) 。 InvalidArgument使用负值设置时引发异常。

属性详细信息

height

注意

此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。

指定图片的高度(以磅为单位)。 如果未提供,则默认值为 72 磅 (1 英寸) 。 InvalidArgument使用负值设置时引发异常。

height?: number;

属性值

number

注解

API 集:PowerPointApi BETA (仅预览版)

left

注意

此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。

指定从图片左侧到幻灯片左侧的距离(以磅为单位)。 如果未提供,则默认值为 0。

left?: number;

属性值

number

注解

API 集:PowerPointApi BETA (仅预览版)

top

注意

此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。

指定从图片上边缘到幻灯片上边缘的距离(以磅为单位)。 如果未提供,则默认值为 0。

top?: number;

属性值

number

注解

API 集:PowerPointApi BETA (仅预览版)

width

注意

此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。

指定图片的宽度(以磅为单位)。 如果未提供,则默认值为 72 磅 (1 英寸) 。 InvalidArgument使用负值设置时引发异常。

width?: number;

属性值

number

注解

API 集:PowerPointApi BETA (仅预览版)