API reference
PPTX.PicturePPTX.PresentationPPTX.SlidePPTX.TablePPTX.TableCellPPTX.TextBoxPPTX.TextStylePPTX.list_layoutnames
PPTX.Picture — TypePicture(source::String; top::Int=0, left::Int=0, size::Int = 40)source::Stringpath of image filetop::Intmm from the topleft::Intmm 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="My Presentation",
author::String="PPTX.jl",
)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", author = "PPTX.jl")
Presentation with 1 slide
title is "My Presentation"
author is "PPTX.jl"
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::Stringtitle text placed inside the title textbox found in the slide layoutlayout::Intwhich 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,
column_widths::Vector{<:Real}, # set size per column
row_heights::Vector{<:Real}, # set size per row
header::Bool = true, # whether to automatically write the columnnames as headers
bandrow::Bool = true, # whether to use alternating coloring per row
)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.
To style each cell individually see TableCell.
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 DataFrames.DataFrame
offset_x is 1800000 EMUs
offset_y is 1800000 EMUs
size_x is 1080000 EMUs
size_y is 3600000 EMUs
PPTX.TableCell — TypeTableCell(
content; # text
textstyle = TextStyle(),
color = nothing, # background color of the table element
anchor = nothing, # anchoring of text in the cell, can be "top", "bottom" or "center"
lines,
margins,
)Create a styled TableCell for use inside a table/dataframe.
Example
julia> t = TableCell(4; color = :green, textstyle=(color=:blue,))
TableCell
text is 4
textstyle has
color is 0000FF
background color is 008000
PPTX.TextBox — Typefunction TextBox(;
content::String = "",
offset = (50,50), # millimeters
offset_x = offset[1],
offset_y = offset[2],
size = (40,30), # millimeters
size_x = size[1],
size_y = size[2],
hlink = nothing, # hyperlink
color = nothing, # use hex string, or Colorant
linecolor = nothing, # use hex string, or Colorant
linewidth = nothing, # use value in points, e.g. 3
rotation = nothing, # use a value in degrees, e.g. 90
textstyle = (italic = false, bold = false, fontsize = nothing),
margins = nothing, # e.g. (left=0.1, right=0.1, bottom=0.1, top=0.1) in millimeters
wrap = false, # wrap text in shape or not
)A TextBox to be used on a Slide. Offsets and sizes are in millimeters, but will be converted to EMU.
See TextStyle for more text style options.
Examples
using PPTX
text = TextBox(
content="Hello world!",
offset=(100, 50),
size=(30,50),
textstyle=(color=:white, bold=true),
color=:blue,
linecolor=:black,
linewidth=3
)
# output
TextBox
content is "Hello world!"
content.style has
bold is true
color is FFFFFF
offset_x is 3600000 EMUs
offset_y is 1800000 EMUs
size_x is 1080000 EMUs
size_y is 1800000 EMUs
color is 0000FF
linecolor is 000000
linewidth is 38100 EMUs
PPTX.TextStyle — TypeTextStyle(
bold = false,
italic = false,
underscore = false,
strike = false,
fontsize = nothing,
typeface = nothing, # or a string, like "Courier New"
color = nothing, # anything compliant with Colors.jl
align = nothing, # "left", "right" or "center"
)Style of the text inside a TextBox. You can use Colors.jl colorants for the text color, or directly provide a HEX string, or a symbol like :white.
julia> using PPTX
julia> style = TextStyle(bold=true, color=:red)
TextStyle
bold is true
italic is false
underscore is false
strike is false
fontsize is nothing
typeface is nothing
color is FF0000
align is nothing
julia> text = TextBox(content = "hello"; style)
TextBox
content is "hello"
content.style has
bold is true
color is FF0000
offset_x is 1800000 EMUs
offset_y is 1800000 EMUs
size_x is 1440000 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::StringDesired presentation filepath.pres::PresentationPresentation object to write.overwrite = falseargument for overwriting existing file.open_ppt = trueopen powerpoint after it is written.template_path::Stringpath 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)PPTX.list_layoutnames — Functionlist_layoutnames(template_path = DEFAULT_TEMPLATE_DATA)List layout names defined in the template.