问题
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.
Method: presentations.create | Slides 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">>
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.
回答1:
I found a workaround for this problem.
- 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
Then, we get a new presentation. Though we can't decide PageSize dynamically, this works fine for me.
来源:https://stackoverflow.com/questions/41658618/cannot-create-a-presentation-with-pagesize-on-google-slides-api