Documentation
¶
Overview ¶
Package msdoc opens the Word documents of Word 97 to Word 2003: .doc files and .dot templates (MS-DOC). It also reads the text of a document of Word 6 or Word 95, with the properties of its characters and its paragraphs.
A Word document is a Compound File, which the package cfb of magic reads. The package reads the File Information Block, the piece table and the text of the main document, with the bold, the italic, the underline, the size, the color, the border and the font of each run, the alignment, the indents, the spacing and the tab stops of each paragraph, and the headings of the style sheet. It converts the text into HTML, with each table as an HTML table, for the layout of ivy (D10). Each section has pages of its own size and margins, with its headers, its footers and its columns. The layout makes the margins of a page larger for a header or a footer that needs it. A section break starts a new page, unless the next section is continuous on a page of the same size. The tables have the borders, the shading and the merged cells of their rows. The lists have their numbers and their bullets, with the indents and the tab stops of their levels. A table or a frame that floats is at its position, and the text wraps around it when it leaves room beside it. Its vertical position from the margin or from the page holds only when it starts a page, because the layout places a float at the line of its paragraph. The pictures of the stream Data and the shapes of Office Drawing that float on the page show. internal/odraw draws the shapes, as it draws those of msppt and msxls (D51): the preset shapes, the freeforms, the lines with their arrowheads, the groups, the pictures with their crops and turns, and the WordArt. Each shape goes into the layout as a box whose content is a display list. A text box shows its text over the box of its shape, and the text of a shape of a group shows over the box of the group. A footnote goes at the foot of its page, and the endnotes go at the end of the document. A run gives its East Asian font after its font, and the language of its East Asian text.
The package leaves out the comments. A WordArt that bends its text, such as an arch, shows its text straight. The codes of the fields are left out, and their results stay, but the page numbers of the fields PAGE and NUMPAGES come from the layout. Of a document of Word 6 or Word 95, the package leaves out the headers, the footers, the footnotes, the text boxes, the lists, the pictures and the properties of the tables.
A document gives its thumbnail and its properties from the stream "\x05SummaryInformation". A document that a password protects with RC4, RC4 CryptoAPI or the XOR obfuscation asks for the password as D12 says. The package returns an error that wraps ivy.ErrUnsupported for a document of Word 6 or Word 95 that a password protects.
Index ¶
- Variables
- type Document
- func (d *Document) Close() error
- func (d *Document) Describe(ctx context.Context) (ivy.Info, error)
- func (d *Document) Page(ctx context.Context, n int) (ivy.Page, error)
- func (d *Document) PageCount(ctx context.Context) (int, error)
- func (d *Document) Previews(ctx context.Context) iter.Seq2[ivy.Preview, error]
- func (d *Document) Template() bool
- type Option
Constants ¶
This section is empty.
Variables ¶
var Format = ivy.Format{ Name: "msdoc", Mimes: []string{"application/msword", "application/vnd.ms-word", "application/x-msword"}, Exts: []string{"doc", "dot"}, 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 Word document.
func Open ¶
Open opens a Word document. It reads the summary information, the FIB, the piece table, the style sheet and the formatted disk pages, and decrypts the document if a password protects it. It returns an error that wraps ivy.ErrFormat if src is not a Word document, one that wraps ivy.ErrPassword if the password is missing or wrong, and one that wraps ivy.ErrUnsupported for a document of Word 6 or Word 95 with a password, or for a FIB of Word 97 with the nFib of an older version.
func (*Document) Describe ¶
Describe satisfies the ivy.Describer interface. It returns the properties of the summary information, and the language of the FIB.
func (*Document) Page ¶
Page satisfies the ivy.Pager interface. It lays out the document only as far as page n.
func (*Document) PageCount ¶
PageCount satisfies the ivy.Pager interface. It lays out the whole document on its first call.