PPTXLibPowerPoint files for Ring

PPTWriter

The class that builds a presentation: slides, text, lists, shapes, images, tables, notes and saving.

PPTWriter Class#

Constructor#

Ring
ppt = new PPTWriter()

Creates a new PowerPoint presentation.

Document Properties#

MethodDescription
setAuthor(author)Set document author
setTitle(title)Set document title
setSubject(subject)Set document subject
setCompany(company)Set company name

Layout Settings#

MethodDescription
setLayout(layout)Set slide layout (see constants)
setCustomSize(width, height)Set custom size in inches

Layout Constants:

Ring
ppt.setLayout(PPT_LAYOUT_4x3)
ppt.setCustomSize(13.333, 7.5)  # Custom widescreen

Slide Management#

MethodDescription
addSlide()Add a blank slide
addTitleSlide(title, subtitle)Add a title slide
addContentSlide(title, content)Add slide with title and content
addTwoColumnSlide(title, left, right)Add two-column slide
selectSlide(index)Select slide by index (1-based)
getSlideCount()Get number of slides

Slide Background#

MethodDescription
setBackground(color)Set solid background color
setBackgroundImage(path)Set background image
Ring
ppt.addSlide()
ppt.setBackground("1E2761")  # Dark blue
ppt.setBackground("navy")    # Named color

Text Elements#

addTitle#

Ring
ppt.addTitle(text)

Adds a title at the top of the slide (36pt, bold).

addSubtitle#

Ring
ppt.addSubtitle(text)

Adds a subtitle below the title area.

addTextBox#

Ring
ppt.addTextBox(text, x, y, width, height, options)

Parameters:

Options:

OptionTypeDescription
:fontSizeNumberFont size in points
:fontNameStringFont name (e.g., "Arial")
:boldBooleanBold text
:italicBooleanItalic text
:underlineBooleanUnderlined text
:colorStringText color (name or hex)
:alignString"left", "center", "right"
:valignString"top", "middle", "bottom"
:bgColorStringBackground color
:borderColorStringBorder color
:borderWidthNumberBorder width in points
Ring
ppt.addTextBox("Hello", 0.5, 1, 9, 1, [
    :fontSize = 24,
    :bold = true,
    :color = "navy",
    :align = "center"
])

Rich Text#

Ring
ppt.addRichText(runs, x, y, width, height, options)

Multiple formats in one text box:

Ring
ppt.addRichText([
    ["Normal ", []],
    ["Bold", [:bold = true]],
    [" and ", []],
    ["Red", [:color = "red"]]
], 0.5, 1.5, 9, 1, NULL)

Lists#

Bullet List#

Ring
ppt.addBulletList(items, x, y, width, height, options)

Numbered List#

Ring
ppt.addNumberedList(items, x, y, width, height, options)

Options:

Ring
ppt.addBulletList([
    "First point",
    "Second point",
    "Third point"
], 0.5, 1.5, 4, 3, [:fontSize = 18])

Shapes#

addShape#

Ring
ppt.addShape(shapeType, x, y, width, height, options)

Shape Types:

Options:

Convenience Methods#

Ring
ppt.addRectangle(x, y, w, h, options)
ppt.addRoundedRectangle(x, y, w, h, options)
ppt.addCircle(x, y, size, options)
ppt.addOval(x, y, w, h, options)
ppt.addLine(x1, y1, x2, y2, options)
Ring
ppt.addRectangle(1, 1, 3, 2, [
    :fillColor = "4472C4",
    :text = "Click Here",
    :fontColor = "FFFFFF"
])

ppt.addCircle(5, 1, 1.5, [:fillColor = "green"])

ppt.addLine(0, 3, 10, 3, [:color = "red", :width = 2])

Images#

Ring
ppt.addImage(imagePath, x, y, width, height)
ppt.addImageCentered(imagePath, y, width, height)

Supported Formats: PNG, JPG, JPEG, BMP, GIF

Ring
ppt.addImage("logo.png", 0.5, 1, 3, 2)
ppt.addImageCentered("chart.jpg", 2, 6, 3)

Tables#

Ring
ppt.addTable(data, x, y, width, height, options)
ppt.addSimpleTable(data, x, y, width, height)
ppt.addStyledTable(data, x, y, w, h, headerColor, evenRowColor)

Options:

Ring
data = [
    ["Name", "Score", "Grade"],
    ["Alice", "95", "A"],
    ["Bob", "87", "B"]
]

ppt.addSimpleTable(data, 0.5, 1.5, 9, 2)

ppt.addStyledTable(data, 0.5, 1.5, 9, 2, "4472C4", "E3F2FD")

Speaker Notes#

Ring
ppt.addNotes(text)

Adds speaker notes to the current slide.

Saving#

Ring
result = ppt.save(filename)

Returns true if successful.

PPTXLib - PowerPoint files for Ring, made with ringdoc.