API reference
PPTX.Picture
— TypePicture(source::String; top::Int=0, left::Int=0, size::Int = 40)
source::String
path of image filetop::Int
mm from the topleft::Int
mm from the left
Internally the sizes are converted EMUs.
Examples
julia> using PPTX
julia> img = Picture(joinpath(PPTX.ASSETS_DIR, "cauliflower.jpg"))
Picture
source is "./cauliflower.jpg"
offset_x is 0 EMUs
offset_y is 0 EMUs
size_x is 1440000 EMUs
size_y is 1475072 EMUs
Optionally, you can set the size_x
and size_y
manually for filetypes not supported by FileIO, such as SVG.
julia> using PPTX
julia> img = Picture(joinpath(PPTX.ASSETS_DIR, "julia_logo.svg"); size_x=40, size_y=30)
Picture
source is "./julia_logo.svg"
offset_x is 0 EMUs
offset_y is 0 EMUs
size_x is 1440000 EMUs
size_y is 1080000 EMUs
PPTX.Presentation
— TypePresentation(
slides::Vector{Slide}=Slide[];
title::String="unknown",
author::String="unknown",
)
Type to contain the final presentation you want to write to .pptx.
If isempty(slides)
then we add a first slide with the Title slide layout.
Examples
julia> using PPTX
julia> pres = Presentation(; title = "My Presentation")
Presentation with 1 slide
title is "My Presentation"
author is "unknown"
PPTX.Slide
— TypeSlide(
shapes::Vector{AbstractShape}=AbstractShape[];
title::String="",
layout::Int=1,
)
shapes::Vector{AbstractShape}
shapes to add to the PowerPoint, can also be pushed afterwardstitle::String
title text placed inside the title textbox found in the slide layoutlayout::Int
which slide layout to use. Typically 1 is the title slide and 2 is the text slide.
Make a Slide for a powerpoint Presentation.
You can push!
any AbstractShape
types into this slide, such as a TextBox
or Picture
.
Examples
julia> using PPTX
julia> slide = Slide(; title="Hello Title", layout=2)
Slide("Hello Title", PPTX.AbstractShape[], 0, 2)
julia> text = TextBox("Hello world!")
TextBox
content is "Hello world!"
offset_x is 1800000 EMUs
offset_y is 1800000 EMUs
size_x is 1440000 EMUs
size_y is 1080000 EMUs
julia> push!(slide, text);
julia> slide
Slide("Hello Title", PPTX.AbstractShape[TextBox], 0, 2)
PPTX.Table
— TypeTable(;
content,
offset_x::Real = 50,
offset_y::Real = 50,
size_x::Real = 150,
size_y::Real = 100,
)
A Table to be used on a Slide.
The content can be anything that adheres to a Tables.jl
interface.
Offsets and sizes are in millimeters, but will be converted to EMU.
Examples
julia> using PPTX, DataFrames
julia> df = DataFrame(a = [1,2], b = [3,4], c = [5,6])
2×3 DataFrame
Row │ a b c
│ Int64 Int64 Int64
─────┼─────────────────────
1 │ 1 3 5
2 │ 2 4 6
julia> t = Table(content=df, size_x=30)
Table
content isa DataFrame
offset_x is 1800000 EMUs
offset_y is 1800000 EMUs
size_x is 1080000 EMUs
size_y is 3600000 EMUs
PPTX.TextBox
— TypeTextBox(;
content::String = "",
offset_x::Real = 50,
offset_y::Real = 50,
size_x::Real = 40,
size_y::Real = 30,
style::Dict = Dict("bold" => false, "italic" => false),
)
A TextBox to be used on a Slide. Offsets and sizes are in millimeters, but will be converted to EMU.
Examples
julia> using PPTX
julia> text = TextBox(content="Hello world!", size_x=30)
TextBox
content is "Hello world!"
offset_x is 1800000 EMUs
offset_y is 1800000 EMUs
size_x is 1080000 EMUs
size_y is 1080000 EMUs
Base.write
— MethodBase.write(
filepath::String,
p::Presentation;
overwrite::Bool=false,
open_ppt::Bool=true,
template_path::String="no-slides.pptx",
)
filepath::String
Desired presentation filepath.pres::Presentation
Presentation object to write.overwrite = false
argument for overwriting existing file.open_ppt = true
open powerpoint after it is written.template_path::String
path to an (empty) pptx that serves as template.
Examples
julia> using PPTX
julia> slide = Slide()
julia> text = TextBox("Hello world!")
julia> push!(slide, text)
julia> pres = Presentation()
julia> push!(pres, slide)
julia> write("hello_world.pptx", pres)