Manage document headers and footers.

1. Usage

uniword headers SUBCOMMAND FILE [OPTIONS]

2. Subcommands

Subcommand Description

list FILE

List all headers and footers

add-header FILE TEXT

Add a header to the document

add-footer FILE TEXT

Add a footer to the document

remove FILE

Remove headers or footers by type

3. Options

3.1. list

--json

Output as JSON.

--output, -o (required)

Output file path.

--type

Header/footer type: default, first, or even (default: default).

3.3. remove

--output, -o (required)

Output file path.

--what

What to remove: headers, footers, or all (default: all).

--type

Type to remove: default, first, or even (default: default).

4. Examples

List headers and footers:

uniword headers list document.docx
uniword headers list document.docx --json

Add headers:

uniword headers add-header document.docx "Confidential" -o out.docx
uniword headers add-header document.docx "Title" --type first -o out.docx

Add footers:

uniword headers add-footer document.docx "Page 1" -o out.docx

Remove:

uniword headers remove document.docx --what headers --type default -o out.docx
uniword headers remove document.docx --what all -o out.docx

5. Ruby API

doc = Uniword.load("document.docx")

# List
headers = doc.list_headers
footers = doc.list_footers

# Add
doc.add_header("Confidential", type: "default")
    .add_footer("Page 1")
    .save("output.docx")

# Remove
doc.remove_headers(type: "first")
    .remove_footers(type: "default")
    .save("output.docx")