无法在 Google Slides API 上使用 PageSize 创建演示文稿

hkd*_*net 5 google-slides-api

我正在尝试创建一个新的 4:3 演示文稿,而不是 16:9。

我阅读了这个参考并写了一些 ruby​​ 代码,但它没有用。新演示文稿的高度与我指定的不同。

方法:presentation.create | 幻灯片 API | 谷歌开发者

# foo.rb
require 'google/apis/slides_v1'
Slide = Google::Apis::SlidesV1 # alias
slides_service = Slide::SlidesService.new
# authorize...
new_presentation_object = Slide::Presentation.new(
  title: "test",
  page_size: Slide::Size.new(
    width:  Slide::Dimension.new(magnitude: 6_858_000, unit: 'EMU'),
    height: Slide::Dimension.new(magnitude: 9_141_000, unit: 'EMU')
  )
)
presentation = slide_service.create_presentation(new_presentation_object, fields: "pageSize,presentationId")
presentation.page_size
# => #<Google::Apis::SlidesV1::Size:0x007f99ef1fb630
#  @height=#<Google::Apis::SlidesV1::Dimension:0x007f99ef1f8278 @magnitude=5143500, @unit="EMU">,
#  @width=#<Google::Apis::SlidesV1::Dimension:0x007f99ef1fa550 @magnitude=9144000, @unit="EMU">>
Run Code Online (Sandbox Code Playgroud)

如何创建新的 4:3 演示文稿?
我发现没有 API 可以更改 PageSize 而是 CreatePresentation,但欢迎任何更改 PageSize 的想法。

hkd*_*net 3

我找到了解决这个问题的方法。

\n\n
    \n
  1. 创建一个新的演示文稿。我们使用它作为模板。
  2. \n
  3. 根据需要更改页面大小。请参阅:更改幻灯片的大小 - 文档编辑器帮助
  4. \n
  5. 通过 Google Drive API 复制演示文稿。请参阅:文件:复制 \xc2\xa0|\xc2\xa0 驱动器 REST API \xc2\xa0|\xc2\xa0 Google Developers
  6. \n
\n\n

然后,我们得到一个新的演示文稿。\n虽然我们无法动态决定 PageSize,但这对我来说效果很好。

\n

  • 这是现在最好的办法。根据[文档](https://developers.google.com/slides/reference/rest/v1/presentations/create),CreatePresentation 仅使用输入对象中的演示文稿标题。 (2认同)