odf

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 36 Imported by: 1 module, 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.

Documentation

Overview

Package odf opens OpenDocument files, such as the documents of LibreOffice Writer, Calc, Impress and Draw.

A document gives the thumbnail that every OpenDocument file holds, in Thumbnails/thumbnail.png (D11), and the pages of the texts, the spreadsheets, the presentations and the drawings (D24):

  • A text, of Writer, goes through the layout of the ebooks, with its styles, its lists, the numbers of its headings, its tables, its pictures, its shapes and its charts.
  • A spreadsheet, of Calc, puts each sheet on pages, in order, as printing does, with its pictures and its charts.
  • A presentation, of Impress, or a drawing, of Draw, gives one page for each page of the file, with its shapes, its pictures, its text and its charts.

internal/chart draws the charts of the embedded objects (D27), and odf/internal/drawpage draws the shapes of a text. The other kinds of files, such as a chart or a formula on its own, give no pages, and Page returns an error that wraps ivy.ErrUnsupported. Describe reads the title, the author and the dates of meta.xml.

A file that a password protects opens with the password of ivy.Config, or with the function PasswordFunc of ivy.Config (D12). The package reads Blowfish, the cipher of OpenOffice, AES with PBKDF2, the cipher of ODF 1.2 and 1.3, and AES-GCM with Argon2id, which LibreOffice writes by default for ODF 1.4 (D25).

Index

Constants

This section is empty.

Variables

View Source
var Format = ivy.Format{
	Name: "odf",
	Mimes: []string{
		"application/vnd.oasis.opendocument.text",
		"application/vnd.oasis.opendocument.text-template",
		"application/vnd.oasis.opendocument.text-master",
		"application/vnd.oasis.opendocument.spreadsheet",
		"application/vnd.oasis.opendocument.spreadsheet-template",
		"application/vnd.oasis.opendocument.presentation",
		"application/vnd.oasis.opendocument.presentation-template",
		"application/vnd.oasis.opendocument.graphics",
		"application/vnd.oasis.opendocument.graphics-template",
		"application/vnd.oasis.opendocument.chart",
		"application/vnd.oasis.opendocument.formula",
	},
	Exts: []string{"odt", "ott", "odm", "ods", "ots", "odp", "otp", "odg", "otg", "odc", "odf"},
	Open: func(ctx context.Context, src ivy.Source, cfg ivy.Config) (ivy.Document, error) {
		return Open(ctx, src, WithConfig(cfg))
	},
}

Format describes the package for the registry of a program.

Functions

This section is empty.

Types

type Document

type Document struct {
	// contains filtered or unexported fields
}

Document is an open OpenDocument file.

func Open

func Open(ctx context.Context, src ivy.Source, opts ...Option) (*Document, error)

Open opens an OpenDocument file. It returns an error that wraps ivy.ErrFormat if src is not an OpenDocument file, and one that wraps ivy.ErrPassword if the file is encrypted and the configuration does not give the right password.

func (*Document) Close

func (d *Document) Close() error

Close satisfies the ivy.Document interface.

func (*Document) Describe

func (d *Document) Describe(ctx context.Context) (info ivy.Info, err error)

Describe satisfies the ivy.Describer interface. It reads the metadata of the file, in meta.xml: the title, the subject, the language, the dates, the program that made the file, and the author. The author is meta:initial-creator, who made the file, or else dc:creator, who changed it last. A file without meta.xml says nothing. The metadata is a help, so an entry that is damaged says nothing too, and the fault is logged.

func (*Document) Mime

func (d *Document) Mime() string

Mime returns the mime type that the file declares, such as "application/vnd.oasis.opendocument.text". It is empty if the file does not declare one.

func (*Document) Page

func (d *Document) Page(ctx context.Context, n int) (ivy.Page, error)

Page satisfies the ivy.Pager interface. n counts from 0.

func (*Document) PageCount

func (d *Document) PageCount(ctx context.Context) (int, error)

PageCount satisfies the ivy.Pager interface.

func (*Document) Previews

func (d *Document) Previews(ctx context.Context) iter.Seq2[ivy.Preview, error]

Previews satisfies the ivy.Previewer interface. It lists the thumbnail. The thumbnail of an encrypted file is decrypted when the list reaches it.

type Option

type Option func(*options)

Option is an option of Open.

func WithConfig

func WithConfig(cfg ivy.Config) Option

WithConfig sets the configuration that every format shares.

Directories

Path Synopsis
internal
drawpage
Package drawpage puts the pages of the presentations and the drawings of OpenDocument on pages: Impress and Draw, odp, otp, odg and otg.
Package drawpage puts the pages of the presentations and the drawings of OpenDocument on pages: Impress and Draw, odp, otp, odg and otg.
odfcrypt
Package odfcrypt reads the manifest of an OpenDocument file, and decrypts the entries that a password protects, as part 3 of ODF 1.2 describes in section 3.4 and as OpenOffice wrote them before ODF 1.2:
Package odfcrypt reads the manifest of an OpenDocument file, and decrypts the entries that a password protects, as part 3 of ODF 1.2 describes in section 3.4 and as OpenOffice wrote them before ODF 1.2:

Jump to

Keyboard shortcuts

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