Documentation
      ¶
    
    
  
    
  
    Overview ¶
Package slidesutils provides utilities for working with Google Slides presentations, including creating and managing slides programmatically using the Google Slides API.
This package is intended to streamline common tasks such as creating slides, managing chapters, and interacting with Google Slides presentation objects.
Index ¶
- Constants
 - type Builder
 - func (b *Builder) CreateChapter(ctx context.Context, slide structure.Slide) error
 - func (b *Builder) CreateCover(ctx context.Context, title, subtitle string) error
 - func (b *Builder) CreateNewSlide(ctx context.Context, layoutId string) error
 - func (b *Builder) CreateSlideTitleSubtitleBody(ctx context.Context, slide structure.Slide) error
 - func (b *Builder) InsertImage(ctx context.Context, imageUrl string, ...) error
 
Constants ¶
const ( // ChapterLayoutId represents the layout ID for a chapter slide in the presentation. ChapterLayoutId = "g2ac55f3490c_0_1010" // TitleSubtitleBody represents the layout ID for a slide with a title, subtitle, and body content. TitleSubtitleBody = "g2ac55f3490c_0_1006" // CoverLayout ... CoverLayoutID = "g2ac55f3490c_0_1073" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
	Srv            *slides.Service      // The Google Slides API service client.
	CurrentChapter int                  // Tracks the current chapter number in the presentation.
	CurrentSlide   *slides.Page         // Points to the current slide being manipulated.
	Presentation   *slides.Presentation // The full presentation being managed.
	// contains filtered or unexported fields
}
    Builder encapsulates state and methods for working with a Google Slides presentation. It maintains the current chapter, the current slide, and the overall presentation object.
func NewBuilder ¶
NewBuilder initializes a Builder instance for managing a Google Slides presentation.
This function retrieves the presentation with the specified ID using the provided Google Slides API service client. The resulting Builder is used for creating and managing slides programmatically.
Parameters:
- ctx: A context to manage request lifetime.
 - srv: A Google Slides API service client.
 - presentationId: The ID of the Google Slides presentation to manage.
 
Returns:
- *Builder: A new Builder instance for the specified presentation filled with the Srv and Presentation field.
 - error: An error if the presentation could not be retrieved or if the API call fails.
 
func (*Builder) CreateChapter ¶
CreateChapter creates a new chapter slide in the presentation. It uses the predefined chapter layout and updates the slide with the chapter title and number.
Parameters:
- ctx: A context to manage request lifetime.
 - slide: A structure containing slide information such as title.
 
Returns:
- error: An error if the slide creation or text insertion fails.
 
func (*Builder) CreateCover ¶
CreateCover creates a new cover slide in the presentation. It uses the predefined chapter layout and updates the slide with the chapter title and number.
Parameters:
- ctx: A context to manage request lifetime.
 - slide: A structure containing slide information such as title.
 
Returns:
- error: An error if the slide creation or text insertion fails.
 
func (*Builder) CreateNewSlide ¶
CreateNewSlide creates a new slide in the presentation using the specified layout ID. It updates the Builder's CurrentSlide to reference the newly created slide.
Parameters:
- ctx: A context to manage request lifetime.
 - layoutId: The ID of the layout to be used for the new slide.
 
Returns:
- error: An error if the slide creation fails or if the new slide cannot be matched to the presentation's slide list.
 
func (*Builder) CreateSlideTitleSubtitleBody ¶
CreateSlideTitleSubtitleBody creates a new slide with a title, subtitle, and body content. It uses the predefined layout for title, subtitle, and body.
Parameters:
- ctx: A context to manage request lifetime.
 - slide: A structure containing slide information such as title, subtitle, and body.
 
Returns:
- error: An error if the slide creation or text insertion fails.
 
func (*Builder) InsertImage ¶
func (b *Builder) InsertImage(ctx context.Context, imageUrl string, width, height, translateX, translateY float64) error
InsertImage inserts an image into the current slide of the presentation. The image is positioned and sized according to specified parameters.
Parameters:
- ctx: A context to manage request lifetime.
 - imageUrl: The URL of the image to be inserted.
 - width: The width of the image in EMUs.
 - height: The height of the image in EMUs.
 - translateX: The X translation of the image in EMUs.
 - translateY: The Y translation of the image in EMUs.
 
Returns:
- error: An error if the image insertion fails.