Skip to content

feat: ph_location() could accept css-like percentages (for args left, top, right, height) #684

@markheckmann

Description

@markheckmann

Suggestion

CSS allows for absolute as well percentage values for positioning an entity. I think officer would profit from such a featues as well as it would simplify manually positioning using ph_location().

@davidgohel Please let me know what you think and feel free to assign me the issue :)


Example

Let's assume, I wanted to position a ph 5% from the left with a width of 40% (with regard to the slide width) and put it in the lower third of the slide.

Currently, one needs to store the rpptx object in a variable first, to determine the slide width and height. Then, we need to calculate the positon in inches.

x <- read_pptx()

w <- slide_size(x)$width
h <- slide_size(x)$height

loc <- ph_location(left = .05 * w, width = .4 * w, top = .67*h, height = .33 * h)
x |> 
  add_slide("Title and Content") |> 
  ph_with(value = "Hello darkness my old friend ...", location = loc)

Allowing for percentage values as input to ph_location would eliminate the calculation step and make the code more readable.

loc <- ph_location(left = "5%", width = "40%", top = "67%", height = "33%")
read_pptx() |> 
  add_slide("Title and Content") |> 
  ph_with(value = "Hello darkness my old friend ...", location = loc)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions