odf

package module
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2026 License: BSD-3-Clause Imports: 15 Imported by: 2 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

odf

An ODT (OpenDocument Text) ⇄ richdoc converter, written in pure Go (CGO-free, including GOOS=js). .ods spreadsheets, .odp presentations and .odg drawings are read as well, and a deck of rendered slides is written as an .odp with its speaker notes.

odf reads an .odt package (a ZIP of XML) into the neutral richdoc document model, and writes a minimal, valid OpenDocument Text package from a richdoc.Document. The two directions are designed as a faithful round-trip.

d, err := odf.Parse(src)   // .odt bytes -> *richdoc.Document
out, err := odf.Write(d)   // *richdoc.Document -> .odt bytes (valid ODF package)

src and the return of Write are the raw bytes of the .odt ZIP container. Parse also accepts an .ods spreadsheet, an .odp presentation and an .odg drawing; Write always produces ODT.

Writing a presentation (.odp)

odp, err := odf.WritePresentation(odf.Presentation{
	Width: 1280, Height: 720, // CSS pixels; written as 960pt × 540pt
	Title: "Deck", Author: "Ada", Subject: "…", Keywords: "a, b",
	Slides: []odf.PresentationSlide{
		{Image: png1, ImageType: "png", Notes: "what to say", Name: "Opening"},
	},
})

The same shape as ooxml.WritePresentation in go-ooxml, for the same consumer — a renderer whose output is the slide, as marp-cli --pptx writes it. Each slide is a draw:page holding one full-page draw:frame and draw:image from Pictures/; its Name is the page's draw:name (what Parse reads back as the slide's heading) and the picture's svg:desc; its Notes are a presentation:notes with a thumbnail of the page and one text:p a line — written only for a slide that has notes.

  • The size is in CSS pixels, the unit the slides were rendered in, and is written in points: three quarters of a pixel is a point, so a whole number of pixels is exact to two decimals where centimetres would round.
  • The output is deterministic. No clock is read: Created is written to meta:creation-date and dc:date only when given.
  • The bounds are the reader's: 96 – 5376 px a side (PowerPoint's 1 – 56 inches, so the deck converts), 1000 slides, 64 MiB a picture and 160 MiB of pictures, 1 MiB a text — so what this writes, Parse reads. A picture whose signature is not its ImageType is refused.

Measured 2026-10-19 with LibreOffice: a three-slide deck converts to a three-page PDF, each page the picture edge to edge, and to a .pptx whose notes slides carry the notes.

Editable slides

A slide can hold Shapes (back to front) and a Background instead of, or over, its picture — what an editable deck is made of:

Shape.Kind element (ODF 1.3 Part 3)
ShapeRect draw:rect, draw:corner-radius from Radius
ShapeEllipse draw:ellipse
ShapePath draw:path (§10.3.7): svg:d of lines and cubics in a viewBox of hundredths of a pixel; several outlines whose overlaps are holes, svg:fill-rule="evenodd" (§20.406), or NonZero for svg:fill-rule="nonzero" (an SVG path's default rule)
ShapeText draw:frame + draw:text-box (§10.4.2–10.4.3): one text:p of text:spans — family, size, bold, italic, colour, fo:letter-spacing, a text:a for http, https and mailto links only — with no padding and no wrap
ShapeImage draw:frame + draw:image of Presentation.Images[Image-1], stored once however many slides show it
any, with Group set draw:g (§10.3.15) of those shapes, which a viewer selects and moves as one (an SVG drawing, a formula). It has no box of its own, and its members keep page coordinates. Groups nest up to MaxGroupDepth (32) levels, and every member counts towards the slide's limit. LibreOffice draws a group's text

Fills are a solid colour with draw:opacity. Presentation.Fonts are embedded under Fonts/, deflated, each face a style:font-face whose svg:font-face-src/svg:font-face-uri (§16.23–16.26) points at its file — measured 2026-10-19: LibreOffice 25.8 renders a deck set in Lato, on a machine without Lato, in Lato. Every text is XML-escaped and stripped of the characters XML cannot carry; FuzzEditableText checks content.xml stays well-formed. Bounds: 20 000 shapes a slide (group members included), 64 fonts ≤ 32 MiB, coordinates under 2³⁰ px, sizes 1–4000 pt.

⛔⛔ No .odt this library ever wrote opened in LibreOffice

Found while checking the writer above. archive/zip's CreateHeader writes a stored entry with zero sizes in its local header, flag bit 3, and the real values in a data descriptor after the data. That is legal ZIP, and our own reader — archive/zip again — reads it without a murmur. LibreOffice refuses it for the mimetype entry with nothing more than "source file could not be loaded". Changing that one entry, and nothing else, made the same .odt open. Both writers now write stored entries with CreateRaw and the sizes and CRC computed first; TestWriteMimetypeHasNoDataDescriptor reads the header bytes in CI, and the LibreOffice tests open both kinds of file where it is installed.

Presentations and drawings (.odp, .odg)

office:presentation and office:drawing are the same document: draw:page elements holding shapes, with the words inside them. Walking office:text found nothing in either — the same silence an .ods gave before office:spreadsheet was handled.

Each page becomes a heading of its own name followed by the blocks found in its shapes, so a reader can tell which slide a sentence was on.

⛔ Every rule here was read off a file LibreOffice WROTE

Four of them contradict what the specification alone suggests, and the fixtures in testdata/ are files Impress and Draw produced rather than fixtures written here. A fixture composed by hand tests one's reading of the specification; these test the thing a caller will actually be handed.

the title is not presentation:class="title" the one rule the specification suggests is the one that does not work. Impress strips that attribute from every frame it does not treat as a master-page placeholder, so a converted deck has no classed title frame at all. The heading is the page's own draw:name, which survives a conversion and is always there — dull on an untitled slide, and always right.
presentation:notes is skipped it holds a frame whose text reads exactly like body text. Walking into it puts words the audience never saw into the document as though they had been on screen.
a picture is held back Impress writes a draw:image preview of a table into the same frame as the table — Pictures/TablePreview1.svm. It is emitted only if the shape held nothing else, so a real picture frame keeps its picture and a table does not gain a broken reference, in a format nothing reads, beside the content it is a picture of.
svg:title and svg:desc are the frame's children beside draw:image, not inside it. A reader looking within the image element finds none, and a slide's picture reaches the document with no alternative text — which no page, byte or block count can see.
The shape types are deliberately not enumerated

ODF has dozens — draw:frame, draw:custom-shape, draw:rect, draw:ellipse, draw:polygon, draw:connector, draw:caption, draw:g — and any of them may carry text. A list of the ones that came to mind would silently drop the words in the others, so the walk descends and collects what it meets. The shape's own geometry falls out for free: draw:enhanced-geometry holds no text:p.

A witness, not a restatement

TestNoFrameOnARealDeckIsClassedTitle opens the real .odp and asserts the attribute is absent — and, positively, that the draw:names the heading rule relies on are present. ⛔ Without it the specification's rule could be put back by somebody reading the standard, and every other test would still pass: they assert the words came out, and under draw:name they do.

Spreadsheets (.ods)

A spreadsheet is the same package as a text document — the same ZIP, the same content.xml, the same table:table/-row/-cell elements — inside an office:spreadsheet body instead of an office:text one. So Parse reads one too: each sheet comes back as a level-1 Heading carrying its table:name, followed by the sheet's Table.

⛔ The reader used to walk office:text and nothing else, and the cost of that was silent: an .ods parsed without an error into a document of no blocks, so a conversion handed somebody an empty page and no reason for it. An empty answer and a refusal are different things, and this was neither — it was an empty answer wearing a success. TestASpreadsheetIsReadAtAll is that regression.

Three things a spreadsheet does that running text does not, and each is handled only when the body is office:spreadsheet:

sheet names a workbook of six sheets is otherwise six tables run together with nothing saying where one ends. The name becomes a level-1 heading — a sheet is a top-level division, and demoting it would nest every sheet under whatever came before.
repeat attributes table:number-columns-repeated and -rows-repeated. Running text rarely carries them; a spreadsheet is made of them.
trailing padding every row is squared off to the sheet width with one repeated empty cell. It is dropped — but only from the end: an empty cell between two full ones is a gap in the data and the shape of the row depends on it.

⛔ A repeat is a count in a file, so materialising what it asks for is an allocation the input decides. Capped at 1024 columns and 65536 rows — the formats' own limits rather than round numbers. OpenSSL's own lifecycles.ods pads its rows to 1024 columns and asks for 1 048 559 repeated empty rows; read uncapped and untrimmed, its six sheets would be six tables of a million rows by a thousand columns. Read as written, they are 91 rows and 14 columns.

The caps are tested against literals, not against the constants themselves: the first draft asserted n > maxRepeatRows, so raising the constant raised the assertion with it and the mutation passed. The judge must not move with the subject.

API

func Parse(src []byte) (*richdoc.Document, error)
func Write(d *richdoc.Document) ([]byte, error)
func WritePresentation(p Presentation) ([]byte, error)

Parse opens the ZIP, reads content.xml (resolving span formatting against the automatic styles there and the named styles in styles.xml), consults META-INF/manifest.xml for embedded image media types, and maps the office:text body onto richdoc blocks and inlines. Anything the model has no node for is preserved verbatim through RawInline/RawBlock with Format: "odf", so nothing in the source is silently lost.

Write produces a minimal, valid OpenDocument package: mimetype is the first entry and is stored uncompressed (the ODF package requirement), followed by META-INF/manifest.xml, content.xml, styles.xml, an optional meta.xml, and any embedded Pictures/.

What a package may ask for

An ODF package is a ZIP, and a ZIP says how big it will be once opened. What it says is a number in a file.

⛔ Measured before these limits existed: an .ods of 67 206 bytes whose content.xml inflates to 64 MiB parsed without complaint and held 222.9 MiB — a thousandfold on disk, and better than three times the inflated size in the heap, because the bytes are read, decoded as UTF-8, then kept as runs. Nothing in the package has to be plausible for that to work; deflate simply likes repetition.

any one entry, opened 64 MiB refused from its declared size, before a byte is inflated
the whole package 192 MiB one entry under the ceiling says nothing about a thousand of them
entries 8 192 it decides an allocation made before anything is read
nesting 256 the bytes are small and it is the shape that costs
pages 65 536 a page costs a heading and a walk, so the ceiling is generous; it is there so that a file claiming four million pages is refused rather than walked

For scale: the content.xml of OpenSSL's own six-sheet lifecycles.ods — a workbook that pads every row to 1024 columns and asks for a million rows — is 96 453 bytes. These leave it six hundred times its size.

Where a guard goes is not where the code recurses

⛔ The nesting bound was first written where this package recurses, in parseBlock. It caught nothing: a table inside a table cell never reaches parseBlock, because parseCell hands anything that is not a paragraph to the decoder's Skip, which walks it without this package seeing an element. The memory was never in our document tree — it was in encoding/xml's own stack of open elements. A guard placed where the recursion is, rather than where the cost is, passes its own test and stops nothing.

Two guards were removed rather than kept

A check on the bytes actually read looks obviously necessary beside a check on the declared size. It is not: archive/zip makes the declaration binding, and refuses during the read. ⛔ An unreachable guard is not defence in depth; it is a claim nobody has tested. What is left is a dependency, and TestAnEntryThatHoldsMoreThanItDeclaresIsRefused pins it, so a future Go that stopped bounding the read turns that test red rather than quietly removing this package's ceiling.

What is not a risk here

encoding/xml expands no custom entities and fetches no external ones, so billion laughs and an <!ENTITY x SYSTEM "file:///etc/passwd"> are both refused by the decoder itself — measured, in both directions, not assumed.

Reference-library note

Before writing this converter, the maintained Go landscape was checked. No maintained library offers a bidirectional ODT reader/writer over a neutral model: sbinet.org/x/odf is read-only, knieriem/odf and AlexJarrah/go-ods target spreadsheets (ODS) but expose cell grids rather than a document model, kpmy/odf is a one-way generator, and the cat family only extracts plain text. An ODT is a ZIP of XML that the Go standard library (archive/zip + encoding/xml) handles directly, so an in-org converter that maps ODF onto richdoc is justified. The package depends only on the standard library and richdoc.

Construct mapping

Both directions map as follows:

ODF (content.xml) richdoc
office:spreadsheet → table:table + table:name Heading (level 1) + Table
table:number-columns-repeated / -rows-repeated (sheets only) that many columns / rows, capped
text:h + text:outline-level Heading (level 1–6)
text:p Paragraph
text:span → fo:font-weight="bold" Strong
text:span → fo:font-style="italic" Emph
text:span → style:text-line-through-style (≠ none) Strikethrough
text:span → monospace style:font-name Code (inline)
text:a (xlink:href, office:title) Link
draw:frame/draw:image (+ svg:desc/svg:title) Image
text:line-break LineBreak
text:tab, text:s whitespace Text
text:list / text:list-item (number style ⇒ ordered) List / ListItem
table:table / table:table-row / table:table-cell Table
text:p + odfgo:code-language CodeBlock
text:section + odfgo:blockquote BlockQuote
text:p + odfgo:thematic-break ThematicBreak
text:p/text:span + odfgo:math MathBlock / Math
text:note (footnote/endnote) Footnote
text:bookmark / text:bookmark-start Anchor
text:reference-ref / text:bookmark-ref (text:ref-name) CrossRef
any unrecognized element RawBlock / RawInline (Format: "odf")

The odfgo: attributes live in a private namespace (https://github.com/go-odf/odf); ODF consumers ignore foreign attributes, and they let the converter re-recognize model nodes (code blocks, block quotes, thematic breaks, math) that OpenDocument has no dedicated element for on the way back in.

Footnotes. A text:note becomes a Footnote whose body is the block content of text:note-body; the generated text:note-citation marker and the text:id are dropped and regenerated on write (a per-writer ftnN id and sequence number). Both note-class="footnote" and note-class="endnote" map to Footnote, so an endnote normalizes to a footnote on the round-trip.

Bookmarks. A text:bookmark (and the range-opening text:bookmark-start) maps to a point Anchor{ID}; a stray text:bookmark-end is consumed and produces no node. Write emits the point form text:bookmark. If an Anchor carries Inlines, they are written adjacent to the bookmark so the visible text is never lost, but the exact round-trip target is Anchor{ID} with empty Inlines ⇄ <text:bookmark>.

Cross-references. Parse accepts both text:reference-ref and text:bookmark-ref (reading text:ref-name); Write emits text:bookmark-ref, the natural pair for the text:bookmark it writes for an Anchor. ODF has no first-class citation element, so a CrossRef of kind RefCite is a best-effort text:bookmark-ref tagged odfgo:cite="true", which Parse restores to RefCite; without that attribute a ref parses as RefLabel.

Model boundaries (routed through Raw)

OpenDocument constructs the richdoc model still has no node for — annotations (office:annotation), tables of contents / indexes (text:table-of-content, text:*-index), reference marks (text:reference-mark*), and any other unrecognized element — are carried through unchanged as RawInline/RawBlock with Format: "odf", captured as the exact original XML bytes so nothing is lost.

Embedded images have no byte field in richdoc.Image, so an embedded picture is surfaced as a data: URI in Image.URL (and re-embedded on write); external http(s) references pass through as-is.

License

BSD-3-Clause. Copyright (c) the go-odf authors.

Documentation

Overview

Package odf converts between ODT (OpenDocument Text) packages and the neutral github.com/go-richdoc/richdoc document model, and reads ODS (OpenDocument Spreadsheet), ODP (OpenDocument Presentation) and ODG (OpenDocument Graphics) packages as well. WritePresentation writes a deck of rendered slides as an ODP package, one full-page picture per slide with its speaker notes.

An ODT file is a ZIP container of XML parts. Parse opens the container, reads content.xml (resolving inline formatting against the automatic styles there and the named styles in styles.xml), consults META-INF/manifest.xml for embedded image media types, and maps the office:text body onto richdoc blocks and inlines. Write produces a minimal, valid OpenDocument Text package: the mimetype entry is written first and stored uncompressed, as the OpenDocument packaging specification requires.

The two directions are designed as a faithful round-trip: Parse(Write(d)) is semantically equal to d for the supported model.

Presentations and drawings

office:presentation and office:drawing are the same document: draw:page elements holding shapes, with the words inside them. Each page becomes a heading of its own draw:name followed by the blocks found in its shapes, so a reader can tell which slide a sentence was on.

The rules were read off files LibreOffice wrote, and four of them contradict what the specification alone suggests. The title is not the frame with presentation:class="title" — Impress strips that attribute from any frame it does not treat as a master-page placeholder, so a converted deck has none. Speaker notes are skipped: presentation:notes holds a frame whose text reads exactly like body text. A picture is emitted only if its shape held nothing else, because Impress writes a draw:image preview of a table into the same frame as the table. And svg:title and svg:desc are the frame's own children, beside draw:image rather than inside it.

Spreadsheets

A spreadsheet is the same package as a text document, inside an office:spreadsheet body instead of an office:text one, so Parse reads one too: each sheet comes back as a level-1 richdoc.Heading carrying its table:name, followed by the sheet's richdoc.Table. Write always produces ODT.

Only a spreadsheet body honours table:number-columns-repeated and table:number-rows-repeated, and only a spreadsheet body has the padding at the end of each row dropped — an empty cell between two full ones is a gap in the data and stays. A repeat is a count in a FILE, so what it asks for is an allocation the input decides: it is capped at 1024 columns and 65536 rows.

Footnotes, bookmarks and cross-references map onto native ODF elements: richdoc.Footnote ↔ text:note, richdoc.Anchor ↔ text:bookmark, and richdoc.CrossRef ↔ text:bookmark-ref (text:reference-ref is also accepted on parse). ODF has no first-class citation element, so a CrossRef of kind richdoc.RefCite is written as a bookmark-ref tagged with the private attribute odfgo:cite="true" that Parse restores to RefCite; an ODF endnote is normalized to a Footnote on the round-trip.

OpenDocument has no dedicated element for several other richdoc nodes (code blocks, block quotes, thematic breaks, inline/display math); those are written using standard ODF container elements tagged with attributes in a private namespace ("https://github.com/go-odf/odf"), which ODF consumers ignore and which let Parse re-recognize the node. Any remaining unrecognized element is preserved verbatim through richdoc.RawInline / richdoc.RawBlock with Format "odf", so nothing in the source is lost.

The package is pure Go and builds with CGO disabled, including for GOOS=js/GOARCH=wasm.

Index

Constants

View Source
const MaxGroupDepth = 32

MaxGroupDepth bounds how deep groups nest: a reader walks the tree recursively.

Variables

This section is empty.

Functions

func Parse

func Parse(src []byte) (*richdoc.Document, error)

Parse converts the bytes of an ODT (OpenDocument Text) package into a richdoc.Document.

It opens the ZIP container, resolves inline formatting in content.xml against the automatic styles there and the named styles in styles.xml, reads embedded image bytes (surfaced as data: URIs) using META-INF/manifest.xml for their media types, and reads document metadata from meta.xml. Unrecognized elements are preserved verbatim as richdoc.RawBlock / richdoc.RawInline with Format "odf". A container that is not a ZIP, that lacks content.xml, that holds a corrupt entry, or whose XML is malformed returns an error.

func Write

func Write(d *richdoc.Document) ([]byte, error)

Write renders a richdoc.Document as the bytes of a minimal, valid OpenDocument Text (.odt) package.

The returned ZIP always begins with a stored (uncompressed) mimetype entry, as the OpenDocument packaging specification requires, followed by META-INF/manifest.xml, content.xml, styles.xml, an optional meta.xml (when the document carries metadata) and any embedded Pictures/. Inline formatting is generated as automatic text styles in content.xml.

Write is the inverse of Parse over the supported model: parsing Write's output reproduces the input tree. An richdoc.Image whose URL is a data: URI is decoded and re-embedded; a malformed data: URI is the only input that makes Write fail.

func WritePresentation added in v0.8.0

func WritePresentation(p Presentation) ([]byte, error)

WritePresentation writes a deck as an OpenDocument Presentation package (.odp): mimetype first and STORED, the manifest, content.xml, styles.xml, meta.xml when there are properties, and the pictures under Pictures/.

A slide is a picture (as in marp-cli's --pptx), editable shapes (Shapes: rectangles, ellipses, paths, text boxes and pictures, in fonts the package can embed), or both. Parse reads back each slide's name, pictures and the text boxes' words.

⛔ The output is deterministic: the same Presentation gives the same bytes. No clock is read (see Presentation.Created) and every name is a position.

Types

type Font added in v0.9.0

type Font struct {
	Family                          string
	Regular, Bold, Italic, BoldItal []byte
}

Font is a typeface embedded in the package (style:font-face with an svg:font-face-uri, §16.23–16.26): TrueType data for each of its faces, any of which may be nil. Embed only fonts whose licence allows it.

type Image added in v0.9.0

type Image struct {
	Data []byte
	Type string // "png" or "jpeg"
}

Image is a picture shapes refer to by its position in Presentation.Images, plus one, stored once however many slides show it.

type PathCmd added in v0.9.0

type PathCmd struct {
	Op byte
	P  [3][2]float64
}

PathCmd is one command of a path: 'M' move to P[0], 'L' line to P[0], 'C' cubic Bézier through P[0] and P[1] to P[2], 'Z' close; in pixels.

type Presentation added in v0.8.0

type Presentation struct {
	Width, Height int
	Slides        []PresentationSlide

	// The document properties, written to meta.xml when set: dc:title,
	// dc:creator, dc:subject, and one meta:keyword for each comma-separated
	// item of Keywords.
	Title, Author, Subject, Keywords string

	// Created is written as meta:creation-date and dc:date. The zero time
	// writes neither, which is what makes the output the same bytes for the
	// same input.
	Created time.Time

	// Images are the pictures editable slides' shapes show (Shape.Image),
	// each stored once however many slides show it.
	Images []Image

	// Fonts are typefaces embedded in the package for viewers that do not
	// have them.
	Fonts []Font
}

A Presentation is a deck to write as an .odp: one full-slide picture per slide, with its speaker notes.

Width and Height are the slide size in CSS pixels, 96 to the inch — the unit the slides were rendered in. They are written in points, three quarters of a pixel each, which is exact: a whole number of pixels is at most two decimals of a point, where centimetres would round.

type PresentationSlide added in v0.8.0

type PresentationSlide struct {
	// Image is the picture, stretched over the whole slide; render it at the
	// slide's aspect ratio. ImageType is "png" or "jpeg", and is checked
	// against the image's own signature. It may be left out when the slide
	// has Shapes or a Background.
	Image     []byte
	ImageType string

	// Background is the page's fill; nil leaves it unfilled.
	Background *RGBA

	// Shapes are the slide's editable content, back to front.
	Shapes []Shape

	// Notes are the speaker notes, one paragraph per line. Empty writes no
	// presentation:notes.
	Notes string

	// Name is the page's draw:name — what Impress shows in its slide pane and
	// what [Parse] reads back as the slide's heading — and the picture's
	// svg:desc, which is what a screen reader says for a slide that is a
	// picture. Empty gives "Slide N".
	Name string
}

A PresentationSlide is one slide: a picture that covers it, or editable shapes, or both (the picture at the back), and its notes.

type RGBA added in v0.9.0

type RGBA struct{ R, G, B, A uint8 }

RGBA is a colour with an alpha: 255 is opaque.

type Shape added in v0.9.0

type Shape struct {
	X, Y, W, H float64

	// Kind selects the element: ShapeRect (draw:rect, corners of Radius
	// pixels), ShapeEllipse (draw:ellipse), ShapePath (draw:path, §10.3.7:
	// Paths, closed outlines relative to the box, whose overlaps are holes,
	// svg:fill-rule evenodd), ShapeText (a draw:frame holding a
	// draw:text-box, §10.4.2–10.4.3, one paragraph of Text with no padding
	// and no wrapping) or ShapeImage (a draw:frame holding a draw:image of
	// Presentation.Images[Image-1]).
	Kind   ShapeKind
	Radius float64
	Paths  [][]PathCmd
	Text   []TextRun
	Image  int

	// Fill is the inside's colour; a zero alpha is no fill.
	Fill RGBA

	// NonZero fills a ShapePath by the nonzero rule instead of evenodd
	// (svg:fill-rule, §20.406): what an SVG path filled by its default rule
	// needs, where subpaths drawn the same way round overlap without a hole.
	NonZero bool

	// Name is the draw:name; for a picture it is also its svg:desc.
	Name string

	// Group, when not empty, makes the shape a group (draw:g, §10.3.15) of
	// these shapes, which a viewer selects and moves as one: an SVG drawing,
	// a formula. A draw:g has no box of its own: its members are placed in
	// page coordinates like any shape, and Kind and the rest are ignored. A
	// group may hold groups, MaxGroupDepth deep; every shape in it counts
	// towards the slide's limit.
	Group []Shape
}

A Shape is one element of an editable slide (ODF 1.3 Part 3 §10.3, §10.4): a rectangle, an ellipse or a path filled with a colour, a text box, or a picture. Shapes are drawn in order, the first at the back.

Positions and sizes are in CSS pixels, as the slide's own size is.

type ShapeKind added in v0.9.0

type ShapeKind uint8

ShapeKind is what a Shape is.

const (
	ShapeRect ShapeKind = iota
	ShapeEllipse
	ShapePath
	ShapeText
	ShapeImage
)

The shapes.

type TextRun added in v0.9.0

type TextRun struct {
	Text         string
	Font         string
	Size         float64
	Bold, Italic bool
	Color        RGBA
	Link         string
	// Spacing is added after each character, in points (fo:letter-spacing).
	Spacing float64
}

TextRun is a stretch of text in one style. Font is a typeface name (an embedded one, see Presentation.Fonts, or one the viewer has); Size is in points. Link, when set, is an http, https or mailto URL.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址