pptx_renderer.PPTXRenderer#

class PPTXRenderer(template_path: Union[str, PathLike])[source]#

Bases: object

PPTX Renderer class

This class is used to render a PPTX template by replacing python statements with the result of evaluating the python statements.

template_path#

Path to the PPTX template.

Type:

str

Methods

register_plugin

Register a plugin function.

render

Render PPTXRenderer template and save to output_path.

register_plugin(name: str, func: callable)[source]#

Register a plugin function.

The plugin function should take 2 or more arguments. The first argument is the result of evaluating the python statement. The second argument is a dictionary containing the following keys: - shape: The pptx shape object where the placeholder is present - slide: The pptx slide object where the placeholder is present - slide_no: The slide number where the placeholder is present The remaining arguments are the arguments passed to the plugin function

Parameters:
  • name (str) – Name of the plugin.

  • func (callable) – Function to be registered.

Returns:

None

render(output_path: Union[str, PathLike], methods_and_params: Optional[Dict[str, Any]] = None, skip_failed: bool = False) None[source]#

Render PPTXRenderer template and save to output_path.

Parameters:
  • output_path (str) – Path to the output PPTX file.

  • methods_and_params (dict, optional) – Dictionary of methods and parameters to be used in the template. Defaults to None.

  • skip_failed (bool, optional) – Dont raise an error if some of the statements failed to render. Defaults to False.

Returns:

None