Expand description
High-level API for reading, writing, and converting DOCX documents.
Provides a Python-docx-like interface for working with Word documents.
§Examples
use rdocx::Document;
// Create a new document
let mut doc = Document::new();
doc.add_paragraph("Hello, World!");
doc.save("output.docx").unwrap();
// Open an existing document
let doc = Document::open("existing.docx").unwrap();
for para in doc.paragraphs() {
println!("{}", para.text());
}Re-exports§
pub use paragraph::Alignment;pub use paragraph::BorderStyle;pub use paragraph::DropCap;pub use paragraph::FrameAnchor;pub use paragraph::FrameWrap;pub use paragraph::HyperlinkItemRef;pub use paragraph::HyperlinkRef;pub use paragraph::Paragraph;pub use paragraph::ParagraphBorderEdge;pub use paragraph::ParagraphBorderRef;pub use paragraph::ParagraphFrame;pub use paragraph::ParagraphItemRef;pub use paragraph::ParagraphMark;pub use paragraph::ParagraphMarkRef;pub use paragraph::ParagraphRef;pub use paragraph::ParagraphTextAlignment;pub use paragraph::ParagraphTextDirection;pub use paragraph::SectionBreak;pub use paragraph::TabAlignment;pub use paragraph::TabLeader;pub use paragraph::TabStopRef;pub use paragraph::TextboxTightWrap;pub use run::BreakKind;pub use run::DrawingKind;pub use run::DrawingRef;pub use run::DrawingRelationshipKind;pub use run::FieldDisplaySegmentRef;pub use run::FieldKind;pub use run::FieldRef;pub use run::LegacyHorizontalRuleRef;pub use run::Run;pub use run::RunFontSlot;pub use run::RunItemRef;pub use run::RunProperties;pub use run::RunRef;pub use run::UnderlineStyle;pub use style::ConditionalTableStyle;pub use style::Style;pub use style::StyleBuilder;pub use table::Cell;pub use table::CellBorderEdge;pub use table::CellItemRef;pub use table::CellRef;pub use table::CellTextDirection;pub use table::Row;pub use table::RowHeight;pub use table::RowRef;pub use table::Table;pub use table::TableAnchor;pub use table::TableBorderEdge;pub use table::TableBorderRef;pub use table::TableCellMargins;pub use table::TableConditionalFormatting;pub use table::TableFloatPosition;pub use table::TableFloatX;pub use table::TableFloatY;pub use table::TableLayout;pub use table::TableLook;pub use table::TableOverlap;pub use table::TableRef;pub use table::TableTextDistance;pub use table::TableWidth;pub use table::VerticalAlignment;
Modules§
- paragraph
- Paragraph — a block-level container for runs of text.
- run
- Run — a contiguous stretch of text with uniform formatting.
- style
- Style access and manipulation for documents.
- table
- Table — a block-level container for rows and cells of content.
Structs§
- Accepted
RunPath - A checked recursive address for one visible accepted-view run.
- Accessibility
Issue - An accessibility issue found during audit.
- AppProperties
- Shared application properties from a Word or PowerPoint package.
- Authority
Entry - A nonprinting authority occurrence. Short citations are category-local keys.
- Barcode
Field - A validated generated-barcode request.
- Bibliography
Contributor - One contributor occurrence in source order.
- Bibliography
Options - Formatting style, formatting locale and independent source selection.
- Bibliography
Person - Ordered components of a person’s bibliography name.
- Bibliography
Property - One textual property occurrence in source order.
- Bibliography
Source - Editable standard source data. Unmodelled imported XML remains package-owned.
- Bibliography
Source Info - Source identity and the editable supported projection, when unambiguous.
- Bibliography
Style Info - Preserved collection metadata and its recognized style, when present.
- Bibliography
Update Report - Explicit update results. Unsupported producers retain their complete caches.
- Bookmark
Ref - Immutable summary of one correlated bookmark or one reported marker issue.
- Building
Block - The editable supported projection of one existing glossary entry.
- Building
Block Info - One building block and its stable package-scoped identity.
- CT_
DocGrid CT_DocGrid– thew:docGridcharacter grid of a section.- CT_
East Asian Layout CT_EastAsianLayout—w:eastAsianLayout, two-lines-in-one and vertical text within a run.- CT_
FitText CT_FitText—w:fitText, the twip width a run segment is fitted into.- CT_
OMath - One inline OfficeMath equation.
- CT_
OMath Para - One display OfficeMath paragraph.
- CT_
Office Style Sheet - CT_PPr
CT_PPr— Paragraph properties.- CT_RPr
CT_RPr— Run properties.- CT_Ruby
CT_Ruby— one phonetic guide over a span of paragraph runs.- CT_
Ruby Pr CT_RubyPr— the geometry of one phonetic guide.- Caption
Options - Caption content and its three bookmark targets.
- Caption
Target - Checked caption location and the actual allocated bookmark names.
- Chart
Data - Data used to author one chart and its editable workbook.
- Citation
Options - Citation members and the field-wide formatting locale.
- Citation
Source Options - Per-source citation switches, in source order.
- Comment
Ref - Read-only view of a comment and its thread metadata.
- Comparison
Diagnostic - A comparison difference that cannot be represented as a content revision.
- Comparison
Options - Policy controls for native document comparison.
- Compatibility
Setting - One
w:compatSettingentry from the document compatibility settings. - Content
Control Ref - Read-only view of one structured document tag in document order.
- Content
Fragment - Owned direct story content that can be inserted without a second document tree.
- Content
Location - A checked path to one item inside a story owner.
- Content
Measurement - Caller-width layout measurement for one supported story item.
- Core
Properties - Document metadata from
docProps/core.xml(Dublin Core). - Cross
Reference Options - Checked REF switches, including typed note copying.
- Custom
Property - One property in
docProps/custom.xml. - Document
- A Word document (.docx file).
- Document
Fragment - An owned story range and the package dependencies it can reach.
- Document
Proof State - The spelling and grammar proofing state recorded by
w:proofState. - Document
Protection - One valid
w:documentProtectionelement. - Document
Zoom - The
w:zoommagnification preset and its percentage. - Embedded
Content Info - Stable audit facts for one relationship-owned executable payload.
- Embedded
Font - Caller-owned bytes and metadata for one embedded font face.
- Epub
Diagnostic - One stable report of source content that EPUB cannot preserve exactly.
- Epub
Write Result - Serialized EPUB bytes together with every lossy-conversion diagnostic.
- Field
Date Time - A deterministic civil date and time supplied to field evaluation.
- Field
Evaluation - The result of evaluating one field in document order.
- Field
Evaluation Context - Explicit values that are not stored in the document package.
- Fields
Update Report - Result of one atomic ordinary and layout-backed stored-cache update.
- Font
Definition - One font-table record authored through the native facade.
- Font
Embedding License - The caller’s explicit authorization and exact license identity.
- Fragment
Conflict Policy - Conflict choices for one cross-document fragment import.
- Generated
Tables Report - Counts of materialized entries and stable retained-cache diagnostics.
- Half
Point - Half-points — 1/2 of a point, or 1/144 of an inch. Used for font sizes (e.g., 24 half-points = 12pt).
- Html
Diagnostic - Html
Fragment Insert Result - The direct story range inserted by one HTML fragment operation.
- Html
Image Resource - One caller-owned image available to an HTML fragment insertion.
- Html
Read Result - Image
Info - Information about an image in the document.
- Image
Watermark Options - Appearance of one section-variant image watermark.
- Index
Entry - A nonprinting index marker and its page-number formatting.
- Index
Options - Native INDEX switches and the cached entry leader.
- Layout
Backed Field Update Report - Results of refreshing caches whose values require deterministic layout.
- Legacy
Form Field Info - One legacy form field and its stable story-part identity.
- Legend
Settings - Effective legend settings. An absent legend has right/false defaults.
- Length
- A length measurement that can be expressed in various units.
- Link
Info - Information about a hyperlink in the document.
- List
Level - One level of a custom list definition for
Document::add_list_definition. - Mail
Merge - The bounded
w:mailMergesubset this model authors. - Mail
Merge Data - Root records and reusable named sources for a rich mail merge.
- Mail
Merge Format Context - Stable location metadata supplied to a rich merge formatter.
- Mail
Merge Formatted Text - Text and optional run properties exposed to a rich merge formatter.
- Mail
Merge Image - An image value embedded by a rich mail merge.
- Mail
Merge Record - One rich mail merge record with nested lexical regions.
- Math
Accent - Math
Argument - A recursively nested OfficeMath argument.
- Math
Conversion Diagnostic - One stable source location and message for a lossy equation conversion.
- Math
Conversion Result - A converted value together with every ordered loss diagnostic.
- Math
Delimiter - Math
Fraction - Math
Limit - Math
Matrix - Math
Matrix Properties - Math
Matrix Row - Math
Nary - Math
Paragraph Properties - Math
PreSub Superscript - Math
Properties - Document-wide defaults from
w:settings/m:mathPr. - Math
Radical - MathRun
- Text-bearing OfficeMath run.
- Math
RunProperties - OfficeMath run formatting needed by authoring and layout.
- Math
Script - Base and one script argument, used for subscript and superscript forms.
- Math
SubSuperscript - Mhtml
Diagnostic - Mhtml
Read Result - Mhtml
Write Result - Note
Policy - A complete visible note policy.
startis one-based. - Numbering
Definition - Owned public projection of an abstract numbering definition.
- Numbering
Definition Level - One explicitly identified level in an inspected numbering definition.
- Numbering
Instance - Owned public projection of one numbering instance.
- Numbering
Level - Resolved reader metadata for one numbering definition level.
- Numbering
Level Override - One typed override owned by a numbering instance.
- OdtDiagnostic
- OdtRead
Result - OdtWrite
Result - Serialized ODT bytes together with every lossy-conversion diagnostic.
- Outline
Node - A node in the document outline tree.
- Package
Read Limits - Resource limits applied while expanding an OPC ZIP archive.
- Picture
Anchor - Floating placement for a picture or text box.
- Picture
Crop - Picture crop in DrawingML thousandths of one percent.
- Picture
Occurrence - Frozen facts for one admitted physical picture in a checked paragraph. Relationship IDs identify media, not drawing occurrences.
- Picture
Options - Options for one story-scoped picture.
- Raster
Options - Options for raster image export.
- Redaction
Report - Counts of exact literal replacements made by
Document::redact_text. - Render
Options - Options that select a native document render projection.
- Replacement
Count Mismatch - The pair of a
Document::try_replace_all_expectedbatch whose count differed from the count its caller expected. - Revision
Ref - An immutable view of one tracked revision in the main document.
- RgbColor
- A validated DrawingML sRGB colour.
- RtfDiagnostic
- One stable report of RTF content that could not be represented in DOCX.
- RtfRead
Result - A converted document together with every lossy-conversion diagnostic.
- RtfWrite
Result - Serialized RTF bytes together with every lossy-conversion diagnostic.
- RunPosition
- A stable insertion point between runs in a body paragraph.
- RunRange
- A half-open document run range, inclusive at
startand exclusive atend. - Section
- A mutable borrowed view of one section in document order.
- Section
Ref - An immutable borrowed view of one section in document order.
- Section
Story - The effective header or footer story selected for one section variant.
- Sequence
Options - Switches governing one authored sequence field.
- Settings
Diagnostic - One supported settings child the typed model could not own.
- StoryId
- Stable owner identity for one operation over an opened document.
- Story
Item Ref - A borrowed view of one supported story item.
- Story
Item Snapshot - One owned story-item projection materialized from a single story inventory.
- Story
Range Ref - One immutable pair of accepted-view story positions.
- Story
Revision - One owned tracked revision and the Word story that holds it.
- Story
RunPosition - A stable insertion point between runs in a checked story paragraph.
- Story
RunRange - A half-open run range within one checked story owner.
- Story
Text - The accepted-view text of one story that the body view leaves out.
- Story
Text Item - One direct paragraph or block content control of a
StoryText. - SvgDiagnostic
- One stable diagnostic produced while lowering a page to SVG.
- SvgRender
Result - One self-contained SVG page and its ordered diagnostics.
- Table
OfAuthorities Options - Native category, heading and passim selection for authorities.
- Table
OfFigures Options - A caption-selected TOC, independent of the TOC sequence page-prefix switch.
- TcField
- A validated table-of-contents entry request.
- Text
BoxOptions - Options for one floating Word text box.
- Text
Diagnostic - A diagnostic accompanying an owned accepted text projection.
- Text
Report - The CLI-compatible text presentation and its explicit source scope.
- Text
Watermark Options - Appearance of one section-variant text watermark.
- Theme
Font Language - Default document theme languages from
w:themeFontLang. - TocField
- A validated table-of-contents rebuild request.
- TocRebuild
Report - Outcome produced by one atomic table-of-contents rebuild.
- Twips
- Twips — 1/20 of a point, or 1/1440 of an inch. Used for page dimensions, margins, spacing, indentation.
- Unsupported
XmlRef - A borrowed fact for content the compatibility reader does not model.
- Validation
Finding - One stable section validation fact, in document order.
- Validation
Report - Read-only validation results over the current document.
Enums§
- Accepted
RunPath Segment - One recursive step to a visible accepted-view run.
- Barcode
Case Style - An ITF14 case style accepted by
\c. - Barcode
Kind - A barcode type accepted by Word’s barcode field grammar.
- Barcode
Point OfSale Style - A point-of-sale style accepted by
\p. - Bibliography
Author - Personal or corporate authorship. Corporate is legal only for Author and Performer.
- Bibliography
Contributor Role - A standard contributor role in the ordered author list.
- Bibliography
Source Field - A standard textual source property, including repeated occurrences.
- Bibliography
Source Kind - The seventeen standard bibliography source classifications.
- Bibliography
Style - A pinned installed Word bibliography style edition.
- Body
Content Ref - One body child exposed through the compatibility reader facade.
- Body
Item Ref - One direct child of a document body, in source order.
- Building
Block Kind - The supported classification of a glossary entry.
- Character
Spacing Control - Document-wide character spacing compression behavior.
- Chart
Kind - One supported two-dimensional chart family.
- Comparison
Granularity - The text boundary used when generating content revisions.
- Comparison
Story Kind - A Word story category that can be excluded from document comparison.
- Compatibility
Option - The complete closed
CT_Compaton-off child set. - Cross
Reference Number - Numbering context requested by a cross-reference.
- Crypt
Algorithm Class - The algorithm class recorded by Word.
- Crypt
Algorithm Type - The algorithm type recorded by Word.
- Crypt
Provider Type - The cryptographic provider category recorded by Word.
- Custom
Property Value - A typed value stored in a custom document property.
- Document
View - The document view Word opens with, from
w:view. - Drawing
Horizontal Alignment - Horizontal alignment used instead of a floating drawing offset.
- Drawing
Horizontal Relative From - Horizontal frame used to position a floating Word drawing.
- Drawing
Vertical Alignment - Vertical alignment used instead of a floating drawing offset.
- Drawing
Vertical Relative From - Vertical frame used to position a floating Word drawing.
- Drawing
Wrap - Text wrapping policy for a floating Word drawing.
- Embedded
Content Kind - Executable or host-activated content owned by a Word package.
- Embedded
Font Kind - The font-table slot occupied by an embedded font face.
- Embedded
Mutation Policy - Explicit handling for signature evidence invalidated by an embedded mutation.
- Embedded
Signature State - Presence and known mutation state of signature evidence for one payload.
- Error
- Field
Outcome - A pure field-evaluation decision.
- Fraction
Type - Fraction bar form.
- HdrFtr
Type - Header/footer reference type in section properties.
- Header
Footer Kind - Whether a section story is a header or a footer.
- Issue
Severity - Severity level for accessibility issues.
- Legacy
Form Field Kind - The bounded legacy form kind projected from
w:ffData. - Legacy
Form Field Value - The current value stored by one legacy form field.
- Legend
Position - The five ChartML legend positions.
- Limit
Location - List
Level Restart - Explicit restart behavior for a numbering level.
- List
Level Suffix - The layout item emitted between a list marker and paragraph content.
- List
Number Format - Numbering format for one level of a custom list definition.
- Mail
Merge Control - A validated mail-merge control decision.
- Mail
Merge Destination - The mail-merge destination from
w:destination. - Mail
Merge Document Type - The mail-merge output category from
w:mainDocumentType. - Mail
Merge Value - A scalar value accepted by a rich mail merge field.
- Math
Expression - One expression in the normalized OfficeMath tree.
- Math
Justification - Math
Script Style - Script category for a math run.
- Math
Style - Mathematical glyph style.
- Matrix
Base Justification - Note
Family - Which of Word’s independent note streams a policy governs.
- Note
Number Format - Marker formats the native renderer can reproduce.
- Note
Placement - Boundary at which note content appears.
- Note
Restart - Boundary at which numeric note markers start over.
- Note
Special Record - Special content placed before or after a note that continues across pages.
- Numbering
Format - The numbering format reported by the read-only numbering projection.
- Office
Math - Inline or display OfficeMath at a paragraph boundary.
- PdfConformance
- An archival conformance level supported by the PDF backend.
- Proof
State - Whether Word considers a proofing pass current, from
w:proofState. - Protection
Mode - The editing operation permitted by
w:documentProtection. - Raster
Format - Image container and encoding options for raster output.
- Raster
Output - Encoded raster output.
- Revision
Kind - The modeled tracked-change element kind.
- Revision
Style - How the tracked view marks revisions. The accepted view shows none.
- Revision
View - The tracked-revision projection used for Word layout.
- ST_
DocGrid ST_DocGrid– how a section’s character grid constrains its text.- ST_Em
ST_Em— the emphasis mark onw:em/@w:val.- ST_
PTab Alignment ST_PTabAlignment— how content aligns against a positional tab.- ST_
PTab Leader ST_PTabLeader— the leader drawn across a positional tab gap.- ST_
PTab Relative To ST_PTabRelativeTo— what a positional tab position is measured from.- ST_
Ruby Align ST_RubyAlign— the horizontal distribution of the phonetic line over the base line, onw:rubyAlign/@w:val.- ST_
Text Effect ST_TextEffect— the animated text effect onw:effect/@w:val.- Settings
Diagnostic Reason - Why a supported settings child produced no typed value.
- Special
Character - A Word special character run child.
- Story
Error - A location resolution failure from the container-neutral story API.
- Story
Item Kind - The supported kind of one item in a story.
- Story
Kind - A container in the WordprocessingML story graph.
- Story
Range Kind - The four paired marker families supported by checked story ranges.
- Style
Type - The type of a style.
- Table
Style Region - One conditional table-style region, in Word’s increasing-priority order.
- Text
BoxDirection - Text flow direction inside an authored Word text box.
- TocEntry
Selection - Which TC entries contribute to a table of contents.
- VMerge
- Vertical merge state for a cell.
- Validation
Severity - Severity of a document section validation finding.
- Word
Creation Profile - Completeness and package class for a newly authored Word document.
- Word
Package Class - The package class declared by a Word main document part.
- Zoom
Kind - The magnification preset recorded by
w:zoom.
Functions§
- derive_
font_ key - Derive a deterministic uppercase OOXML key from checked single-face font bytes.
- equation_
from_ latex - Import the supported LaTeX subset into the normalized OfficeMath argument tree.
- equation_
from_ mathml - Import Presentation MathML into the normalized OfficeMath argument tree.
- equation_
to_ latex - Export a normalized OfficeMath argument tree as canonical LaTeX.
- equation_
to_ mathml - Export a normalized OfficeMath argument tree as canonical Presentation MathML.
- validate_
document_ bytes - Validate serialized document bytes without changing a live document. Non-package input and unexplained document-open failures remain errors.
- validate_
document_ file - Validate a document package at a path with the same findings as byte validation.