add_slide() Adds a new slide at a specified position, and populate it with content from ....

update_slide() updates an existing slide from a specific index and populate it with content from ....

move_slide() moves the slide from one index to another.

delete_slide() deletes the slide based on the index.

add_slide(
  pptx,
  layout,
  ...,
  index,
  transition = NULL,
  polish_error_continue = TRUE,
  error_call = current_env()
)

delete_slide(pptx, index, error_call = current_env())

move_slide(pptx, index, to, error_call = current_env())

update_slide(
  pptx,
  index,
  ...,
  transition = NULL,
  polish_error_continue = TRUE,
  error_call = current_env(),
  verbose = getOption("powerup.verbose", default = TRUE)
)

Arguments

pptx

A PowerPoint wrapped in a <pptx_container> object. see load_pptx()

layout

slide layout to use when creating a slide in add_slide()

...

content objects created with content()

index

slide index. By default add_slide() creates a new slide at the end of the slide deck.

transition

Defines the type of transition to use when moving to this slide. See ?slide_transitions to see viable values.

polish_error_continue

Boolean indicating if when an error is throwing in either polishing or converting the placeholder if it should be propagated as an error (FALSE) or just inform the user and continue (TRUE). Defaults to TRUE.

error_call

The execution environment of a currently running function, e.g. caller_env(). The function will be mentioned in error messages as the source of the error. See the call argument of abort() for more information.

to

new index to move the slide to

verbose

if TRUE, some information is cli::cli_inform()ed along the way

Value

a pptx_container object with the slide added, updated, moved, or deleted

Examples


library(powerup)

## Create a new presentation
ppt <- load_pptx()

## adding new slides
ppt <- ppt |>
  ## add first slide with content in title
  add_slide(layout = "Title and Content", 
    content("hello world", ph = ph_title())
  ) |>
  ## add another slide with nothing on it yet
  add_slide(layout = "Title and Content") |> 
  ## slide added at index 2 with content in title and body
  add_slide(layout = "Title and Content", 
    index = 2, 
    content("Hello World", ph = ph_title()), 
    content("This is a body", ph = ph_body())
  )
#> → powerup to add 1 content at slide 1.
#> ✔ Successfully added content to placeholder "Title 1".
#> → powerup to add 2 contents at slide 2.
#> ✔ Successfully added content to placeholder "Title 1".
#> ✔ Successfully added content to placeholder "Content Placeholder 2".
 
## updating an existing slide wit new content
ppt <- ppt |>
   update_slide(index = 1, 
     content("This placeholder now has a value", ph = ph_body())
   )
#> → powerup to add 1 content at slide 1.
#> ✔ Successfully added content to placeholder "Content Placeholder 2".

## moving a slide from index 2 to index 1
ppt <- ppt |>
   move_slide(index = 2, to = 1)

## deleting a slide at index 3
ppt <- ppt |>
   delete_slide(index = 3)