Podium.Presentation (Podium v0.3.0)

Copy Markdown View Source

Internal module managing presentation state, slide collection, and serialization.

This module handles the lifecycle of a presentation: creating from a template, adding slides, and building the final OPC package. Index allocation for slides, charts, images, and media is deferred to serialization time via resolve_indices/1. Most users interact through the Podium facade module.

Summary

Functions

Adds a slide to the presentation. Returns the updated presentation.

Creates a new presentation from an arbitrary template package.

Creates a new presentation from the default template.

Replaces a slide in the presentation (by matching slide ref).

Saves the presentation to a file.

Saves the presentation to an in-memory binary.

Places a chart into a content placeholder. Returns the updated slide.

Sets core document properties (Dublin Core metadata).

Sets presentation-level footer, date, and slide number options.

Sets notes text on a slide. Returns the updated slide.

Places a table into a content placeholder. Returns the updated slide.

Types

t()

@type t() :: %Podium.Presentation{
  content_types: Podium.OPC.ContentTypes.t() | nil,
  core_properties: Podium.CoreProperties.t() | nil,
  footer: keyword() | nil,
  notes_count: non_neg_integer(),
  notes_master_created: boolean(),
  notes_master_partname: String.t(),
  notes_master_rid: String.t() | nil,
  pres_rels: Podium.OPC.Relationships.t() | nil,
  slide_height: non_neg_integer(),
  slide_width: non_neg_integer(),
  slides: [Podium.Slide.t()],
  template: :bundled | :custom,
  template_info: Podium.Template.t() | nil,
  template_parts: map() | nil,
  template_width: non_neg_integer()
}

Functions

add_slide(prs, slide)

@spec add_slide(t(), Podium.Slide.t()) :: t()

Adds a slide to the presentation. Returns the updated presentation.

Raises when the template has no layout at the slide's layout index, or when a placeholder on the slide does not match one the layout defines.

from_template(source, opts \\ [])

@spec from_template(
  binary(),
  keyword()
) :: t()

Creates a new presentation from an arbitrary template package.

source is either a path to a .pptx/.potx file or its bytes. The slide size is taken from the template and coordinates are never scaled. The template must contain no slides.

new(opts \\ [])

@spec new(keyword()) :: t()

Creates a new presentation from the default template.

put_slide(prs, slide)

@spec put_slide(t(), Podium.Slide.t()) :: t()

Replaces a slide in the presentation (by matching slide ref).

save(prs, path)

@spec save(t(), String.t()) :: :ok | {:error, term()}

Saves the presentation to a file.

save_to_memory(prs)

@spec save_to_memory(t()) :: {:ok, binary()} | {:error, term()}

Saves the presentation to an in-memory binary.

set_chart_placeholder(prs, slide, ref, chart_type, chart_data, opts)

@spec set_chart_placeholder(
  t(),
  Podium.Slide.t(),
  atom() | {String.t(), non_neg_integer()},
  atom(),
  struct(),
  keyword()
) :: Podium.Slide.t()

Places a chart into a content placeholder. Returns the updated slide.

The placeholder is addressed either by a bundled-template name or by the {type, idx} pair Podium.Template.inspect/1 reports for it. Position and size are taken from the layout.

set_core_properties(prs, opts)

@spec set_core_properties(
  t(),
  keyword()
) :: t()

Sets core document properties (Dublin Core metadata).

set_footer(prs, opts)

@spec set_footer(
  t(),
  keyword()
) :: t()

Sets presentation-level footer, date, and slide number options.

set_notes(slide, text)

@spec set_notes(Podium.Slide.t(), String.t()) :: Podium.Slide.t()

Sets notes text on a slide. Returns the updated slide.

set_table_placeholder(prs, slide, ref, rows, opts \\ [])

@spec set_table_placeholder(
  t(),
  Podium.Slide.t(),
  atom() | {String.t(), non_neg_integer()},
  [[term()]],
  keyword()
) :: Podium.Slide.t()

Places a table into a content placeholder. Returns the updated slide.

The placeholder is addressed either by a bundled-template name or by the {type, idx} pair Podium.Template.inspect/1 reports for it. Position and size are taken from the layout.