rtf

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 5 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 rtf reads RTF documents: the text of their paragraphs, and the properties in their info group, such as their title, author, and when they were created

Index

Constants

View Source
const ContentType = "application/rtf"

ContentType is the content type of RTF documents

Variables

This section is empty.

Functions

This section is empty.

Types

type Document

type Document struct {
	// The paragraphs of the document's text, which aren't blank, in which a
	// cell of a table is followed by a tab, and a line break is a newline
	Paragraphs []string

	// The properties in the document's info group
	Info Info
}

Document is an RTF document: the text of its paragraphs, and the properties in its info group

func Parse

func Parse(data []byte) *Document

Parse returns the RTF document: the text of its paragraphs, decoded from its code page, such as Windows-1252 or Mac Roman, without the text of its font and style tables, pictures, headers, footers and fields' instructions, and the properties in its info group. A document is read up to its end, or the end of its outermost group, and what isn't RTF is read as text.

type Info

type Info struct {
	Title    string // The document's title
	Subject  string // Its subject
	Author   string // Who wrote it
	Operator string // Who last changed it
	Keywords string // Its keywords
	Comment  string // A comment on it
	Company  string // The author's company
	Manager  string // The author's manager
	Category string // Its category

	// The application which made it, such as "Riched20 5.40.11.2210", or
	// Cocoa, for macOS's text system, such as TextEdit's
	Generator string

	Created time.Time // When it was created
	Revised time.Time // When it was last changed
	Printed time.Time // When it was last printed

	Pages      int // How many pages it had when it was last saved
	Words      int // How many words
	Characters int // How many characters
}

Info is the properties in an RTF document's info group, each of which is empty, or zero, when it isn't set. Its times have no time zone, and are in UTC.

Jump to

Keyboard shortcuts

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