Manage document editing restrictions and password protection.

1. Usage

uniword protect SUBCOMMAND FILE [OPTIONS]

2. Subcommands

Subcommand Description

apply FILE

Apply editing restriction to the document

remove FILE

Remove all protection from the document

info FILE

Display current protection status

3. Protection types

Type Description

read_only

No edits allowed

comments

Only comments allowed

tracked_changes

Only tracked changes allowed

forms

Only form fields editable

4. Options

4.1. apply

--output, -o (required)

Output file path.

--type

Protection type (default: read_only).

--password

Optional password for the protection.

4.2. remove

--output, -o (required)

Output file path.

5. Examples

Apply read-only protection:

uniword protect apply document.docx --type read_only -o protected.docx

Apply with password:

uniword protect apply document.docx --type comments --password secret -o out.docx

Check protection:

uniword protect info document.docx

Remove protection:

uniword protect remove document.docx -o unprotected.docx

6. Ruby API

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

# Apply protection
doc.protect(:read_only, password: "secret").save("protected.docx")
doc.protect(:tracked_changes).save("tracked.docx")

# Check status
doc.protection_active?  # => true/false
doc.protection_info     # => { type: :read_only, password_protected: true }

# Remove
doc.unprotect.save("unprotected.docx")