问题描述
我正在尝试创建一个新的4:3演示文稿,而不是16:9.
I'm trying to create a new 4:3 presentation, not 16:9.
我阅读了此参考资料并编写了一些红宝石代码,但是没有用.新演示文稿的高度与我指定的高度不同.
I read this reference and write some ruby codes, but it didn't work. The new presentation's height is different from what I specified.
方法:presentations.create.幻灯片API || Google Developers
# 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">>
如何创建新的4:3演示文稿?
我没有找到可以更改PageSize的API,而是CreatePresentation,但是欢迎任何更改PageSize的想法.
How do I create a new 4:3 presentation?
I found no API to change PageSize but CreatePresentation, but any ideas to change PageSize are welcome.
推荐答案
我找到了解决此问题的方法.
I found a workaround for this problem.
- 创建一个新的演示文稿.我们以此为模板.
- 根据需要更改PageSize.请参阅:更改幻灯片的大小-文档编辑器帮助
- 通过Google Drive API复制演示文稿.请参阅:文件:复制驱动器REST API Google Developers
- Create a new presentation. We use this as a template.
- Change PageSize as you like. See: Change the size of your slides - Docs editors Help
- Copy the presentation via Google Drive API. See: Files: copy | Drive REST API | Google Developers
然后,我们得到一个新的演示文稿.尽管我们无法动态决定PageSize,但这对我来说很好.
Then, we get a new presentation.Though we can't decide PageSize dynamically, this works fine for me.
这篇关于无法在Google Slides API上使用PageSize创建演示文稿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!