1

我正在以幻灯片的形式仅使用事件中的图像和标题进行演示,每个事件一张幻灯片。一张幻灯片可以包含来自同一事件的 2-8 张图像。

我希望能够在一张幻灯片或整个演示文稿中调整和排列所有图像。但我不知道如何查找或选择所有图像。

我知道如何插入一定大小的形状,但我不知道如何找到已经插入的图像,并调整它们的大小。

function plassering() {
var slide = SlidesApp.getActivePresentation().getSlides()[6];
var shape = slide.insertShape(SlidesApp.ShapeType.RECTANGLE);
shape.setLeft(14).setTop(14).setWidth(690).setHeight(510).setRotation(0);
Logger.log('Left: ' + shape.getLeft()
                + 'pt; Top: ' + shape.getTop()
                + 'pt; Width: ' + shape.getWidth()
                + 'pt; Height: ' + shape.getHeight()
                + 'pt; Rotation: ' + shape.getRotation() + '\u00B0.');
}

标题应该在所有图像的顶部。

4

1 回答 1

1

我知道了!这是针对当前幻灯片的,但我想我可能对所有幻灯片都这样做,一次一张。

function rearrangeImages() {
  //Select current page
  var currentPage = SlidesApp.getActivePresentation().getSelection().getCurrentPage();
  var slide = currentPage;
  //Get all the images of CurrentPage
  var pageElements = slide.getImages();
  //For each image, change the size and position
  for (var i = 0; i < pageElements.length; i++) {
    pageElements[i].select(true);
    var image = pageElements[i];
    var imgWidth = image.getWidth();
    var newWidth = 690; 
    var imgHeight = image.getHeight();
    var forhold = imgHeight/imgWidth;
    var newHeight = forhold*newWidth;
    image.setLeft(14).setTop(14).setWidth(newWidth).setHeight(newHeight).setRotation(0);
    var ui = SlidesApp.getUi();
   // ui.alert (imgWidth);
    pageElements[i].select(false);
  }
}
于 2018-11-22T06:21:40.667 回答