5

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.

ReyAnthonyRenacia
  • 17,219
  • 5
  • 37
  • 56
hkdnet
  • 81
  • 3

1 Answers1

3

I found a workaround for this problem.

  1. Create a new presentation. We use this as a template.
  2. Change PageSize as you like. See: Change the size of your slides - Docs editors Help
  3. 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.

hkdnet
  • 81
  • 3
  • 2
    This is the best way to do it now. Per [the documentation](https://developers.google.com/slides/reference/rest/v1/presentations/create), CreatePresentation only uses the presentation title out of the input object. – Maurice Codik Jan 17 '17 at 15:43
  • This is a link to the Slides API bug. If more people star it, maybe it will get fixed instead of requiring workaround: https://issuetracker.google.com/issues/74602138 – d35348w May 26 '21 at 16:05