如何将 Google Docs 中的 InlineImages 更改为 PositionedImage?

How to change InlineImages in Google Docs to PositionedImage?

Google Apps 脚本中的新 PositionedImage class 提出了很多问题。

  1. 它与当前 In line/Wrap text/Break 图片文本选项的关系如何?我假设它不是 InlineImage,那么它会换行吗?

  2. 图像是否保留其超链接?目前,将图像从内联更改为 wrapped/break 会删除其超链接。

  3. 假设我想将当前 InlineImage 从其当前位置向下移动一个像素。我如何获取 InlineImage 的当前偏移量,将其转换为 PositionedImage,然后转移到 new offset?周围的文字将如何变化?或者它是否可以相对于原始偏移而不必获得实际偏移量?

编辑:显然,实际上没有办法获取 InlineImages 的坐标,因此在 GAS 更改之前第三个问题可能为空。

我刚刚 an older answer 更新了有关 PositionedImage 的新信息 - 它可能有助于回答您的问题。

How does it (PositionedImage) work in relation to the current In line/Wrap text/Break text options for images? I assume its not an InlineImage, so does it wrap text?

PositionedImage 确实不是InlineImage。它锚定在一个段落中,段落文本可以以不同的方式围绕图像流动,具体取决于图像的 PositionedLayout 设置。通过 UI 提供的所有选项都以编程方式得到支持。

Does the image retain its hyperlink (if changing an InlineImage to a PositionedImage)? Currently, changing an image from inline to wrapped/break (via the UI) removes its hyperlink.

无法以编程方式直接将 InlineImage 更改为 PositionedImage。相反,您需要复制 InlineImage blob,删除 InlineImage,然后将新的 PositionedImage 插入到附近或新的段落中。 (我的猜测是,当您通过 UI 进行相同的更改时,这就是幕后发生的事情。)任何超链接都将丢失,并且无法以编程方式将超链接附加到 PositionedImage(目前)。

Let's say I wanted to shift a current InlineImage one pixel down from its current position. How would I get the current offset of the InlineImage, convert it to a PositionedImage, then shift to the new offset? How will surrounding text change? Or can it just be shifted relative to the original, without having to get the actual offset?

如上所述,但定位可能很棘手。请记住,InlineImage 是 BodyFooterSectionHeaderSectionTableCell 元素的子元素。新的 PositionedImage 将锚定在 ParagraphListItem 中。立即,这意味着图像的一些移动,并且可能受到字体、行间距、边距等的影响。此外,您控制的偏移量是相对于锚元素的左上角的 - 所以我们回到相对于以前的 InlineImage 所在的位置,确定 THAT 所在位置的技巧。