% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ph_location.R
\name{ph_location_type}
\alias{ph_location_type}
\title{Location of a placeholder based on a type}
\usage{
ph_location_type(
  type = "body",
  type_idx = NULL,
  position_right = TRUE,
  position_top = TRUE,
  newlabel = NULL,
  id = NULL,
  ...
)
}
\arguments{
\item{type}{placeholder type to look for in the slide layout, one
of 'body', 'title', 'ctrTitle', 'subTitle', 'dt', 'ftr', 'sldNum'.}

\item{type_idx}{Type index of the placeholder. If there is more than one
placeholder of a type (e.g., \code{body}), the type index can be supplied to uniquely
identify a ph. The index is a running number starting at 1. It is assigned by
placeholder position  (top -> bottom, left -> right). See \code{\link[=plot_layout_properties]{plot_layout_properties()}}
for details. If \code{idx} argument is used, \code{position_right} and \code{position_top}
are ignored.}

\item{position_right}{the parameter is used when a selection with above
parameters does not provide a unique position (for example
layout 'Two Content' contains two element of type 'body').
If \code{TRUE}, the element the most on the right side will be selected,
otherwise the element the most on the left side will be selected.}

\item{position_top}{same than \code{position_right} but applied
to top versus bottom.}

\item{newlabel}{a label to associate with the placeholder.}

\item{id}{(\strong{DEPRECATED, use \code{type_idx} instead}) Index of the placeholder.
If two body placeholder, there can be two different index: 1 and 2 for the
first and second body placeholders defined in the layout. If this argument
is used, \code{position_right} and \code{position_top} will be ignored.}

\item{...}{unused arguments}
}
\description{
The function will use the type name of the placeholder (e.g. body, title),
the layout name and few other criterias to find the corresponding location.
}
\details{
The location of the bounding box associated to a placeholder
within a slide is specified with the left top coordinate,
the width and the height. These are defined in inches:

\describe{
\item{left}{left coordinate of the bounding box}
\item{top}{top coordinate of the bounding box}
\item{width}{width of the bounding box}
\item{height}{height of the bounding box}
}

In addition to these attributes, a label can be
associated with the shape. Shapes, text boxes, images and other objects
will be identified with that label in the \emph{Selection Pane} of PowerPoint.
This label can then be reused by other functions such as \code{ph_location_label()}.
It can be set with argument \code{newlabel}.
}
\examples{
library(officer)

# ph_location_type demo ----

loc_title <- ph_location_type(type = "title")
loc_footer <- ph_location_type(type = "ftr")
loc_dt <- ph_location_type(type = "dt")
loc_slidenum <- ph_location_type(type = "sldNum")
loc_body <- ph_location_type(type = "body")


doc <- read_pptx()
doc <- add_slide(doc, "Title and Content")
doc <- ph_with(x = doc, "Un titre", location = loc_title)
doc <- ph_with(x = doc, "pied de page", location = loc_footer)
doc <- ph_with(x = doc, format(Sys.Date()), location = loc_dt)
doc <- ph_with(x = doc, "slide 1", location = loc_slidenum)
doc <- ph_with(x = doc, letters[1:10], location = loc_body)

loc_subtitle <- ph_location_type(type = "subTitle")
loc_ctrtitle <- ph_location_type(type = "ctrTitle")
doc <- add_slide(doc, layout = "Title Slide")
doc <- ph_with(x = doc, "Un sous titre", location = loc_subtitle)
doc <- ph_with(x = doc, "Un titre", location = loc_ctrtitle)

fileout <- tempfile(fileext = ".pptx")
print(doc, target = fileout)
}
\seealso{
Other functions for placeholder location:
\code{\link[=ph_location]{ph_location()}},
\code{\link[=ph_location_fullsize]{ph_location_fullsize()}},
\code{\link[=ph_location_id]{ph_location_id()}},
\code{\link[=ph_location_label]{ph_location_label()}},
\code{\link[=ph_location_left]{ph_location_left()}},
\code{\link[=ph_location_right]{ph_location_right()}},
\code{\link[=ph_location_template]{ph_location_template()}}
}
\concept{functions for placeholder location}
