Skip to main content

Crate rdocx

Crate rdocx 

Source
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§

AcceptedRunPath
A checked recursive address for one visible accepted-view run.
AccessibilityIssue
An accessibility issue found during audit.
AppProperties
Shared application properties from a Word or PowerPoint package.
AuthorityEntry
A nonprinting authority occurrence. Short citations are category-local keys.
BarcodeField
A validated generated-barcode request.
BibliographyContributor
One contributor occurrence in source order.
BibliographyOptions
Formatting style, formatting locale and independent source selection.
BibliographyPerson
Ordered components of a person’s bibliography name.
BibliographyProperty
One textual property occurrence in source order.
BibliographySource
Editable standard source data. Unmodelled imported XML remains package-owned.
BibliographySourceInfo
Source identity and the editable supported projection, when unambiguous.
BibliographyStyleInfo
Preserved collection metadata and its recognized style, when present.
BibliographyUpdateReport
Explicit update results. Unsupported producers retain their complete caches.
BookmarkRef
Immutable summary of one correlated bookmark or one reported marker issue.
BuildingBlock
The editable supported projection of one existing glossary entry.
BuildingBlockInfo
One building block and its stable package-scoped identity.
CT_DocGrid
CT_DocGrid – the w:docGrid character grid of a section.
CT_EastAsianLayout
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_OMathPara
One display OfficeMath paragraph.
CT_OfficeStyleSheet
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_RubyPr
CT_RubyPr — the geometry of one phonetic guide.
CaptionOptions
Caption content and its three bookmark targets.
CaptionTarget
Checked caption location and the actual allocated bookmark names.
ChartData
Data used to author one chart and its editable workbook.
CitationOptions
Citation members and the field-wide formatting locale.
CitationSourceOptions
Per-source citation switches, in source order.
CommentRef
Read-only view of a comment and its thread metadata.
ComparisonDiagnostic
A comparison difference that cannot be represented as a content revision.
ComparisonOptions
Policy controls for native document comparison.
CompatibilitySetting
One w:compatSetting entry from the document compatibility settings.
ContentControlRef
Read-only view of one structured document tag in document order.
ContentFragment
Owned direct story content that can be inserted without a second document tree.
ContentLocation
A checked path to one item inside a story owner.
ContentMeasurement
Caller-width layout measurement for one supported story item.
CoreProperties
Document metadata from docProps/core.xml (Dublin Core).
CrossReferenceOptions
Checked REF switches, including typed note copying.
CustomProperty
One property in docProps/custom.xml.
Document
A Word document (.docx file).
DocumentFragment
An owned story range and the package dependencies it can reach.
DocumentProofState
The spelling and grammar proofing state recorded by w:proofState.
DocumentProtection
One valid w:documentProtection element.
DocumentZoom
The w:zoom magnification preset and its percentage.
EmbeddedContentInfo
Stable audit facts for one relationship-owned executable payload.
EmbeddedFont
Caller-owned bytes and metadata for one embedded font face.
EpubDiagnostic
One stable report of source content that EPUB cannot preserve exactly.
EpubWriteResult
Serialized EPUB bytes together with every lossy-conversion diagnostic.
FieldDateTime
A deterministic civil date and time supplied to field evaluation.
FieldEvaluation
The result of evaluating one field in document order.
FieldEvaluationContext
Explicit values that are not stored in the document package.
FieldsUpdateReport
Result of one atomic ordinary and layout-backed stored-cache update.
FontDefinition
One font-table record authored through the native facade.
FontEmbeddingLicense
The caller’s explicit authorization and exact license identity.
FragmentConflictPolicy
Conflict choices for one cross-document fragment import.
GeneratedTablesReport
Counts of materialized entries and stable retained-cache diagnostics.
HalfPoint
Half-points — 1/2 of a point, or 1/144 of an inch. Used for font sizes (e.g., 24 half-points = 12pt).
HtmlDiagnostic
HtmlFragmentInsertResult
The direct story range inserted by one HTML fragment operation.
HtmlImageResource
One caller-owned image available to an HTML fragment insertion.
HtmlReadResult
ImageInfo
Information about an image in the document.
ImageWatermarkOptions
Appearance of one section-variant image watermark.
IndexEntry
A nonprinting index marker and its page-number formatting.
IndexOptions
Native INDEX switches and the cached entry leader.
LayoutBackedFieldUpdateReport
Results of refreshing caches whose values require deterministic layout.
LegacyFormFieldInfo
One legacy form field and its stable story-part identity.
LegendSettings
Effective legend settings. An absent legend has right/false defaults.
Length
A length measurement that can be expressed in various units.
LinkInfo
Information about a hyperlink in the document.
ListLevel
One level of a custom list definition for Document::add_list_definition.
MailMerge
The bounded w:mailMerge subset this model authors.
MailMergeData
Root records and reusable named sources for a rich mail merge.
MailMergeFormatContext
Stable location metadata supplied to a rich merge formatter.
MailMergeFormattedText
Text and optional run properties exposed to a rich merge formatter.
MailMergeImage
An image value embedded by a rich mail merge.
MailMergeRecord
One rich mail merge record with nested lexical regions.
MathAccent
MathArgument
A recursively nested OfficeMath argument.
MathConversionDiagnostic
One stable source location and message for a lossy equation conversion.
MathConversionResult
A converted value together with every ordered loss diagnostic.
MathDelimiter
MathFraction
MathLimit
MathMatrix
MathMatrixProperties
MathMatrixRow
MathNary
MathParagraphProperties
MathPreSubSuperscript
MathProperties
Document-wide defaults from w:settings/m:mathPr.
MathRadical
MathRun
Text-bearing OfficeMath run.
MathRunProperties
OfficeMath run formatting needed by authoring and layout.
MathScript
Base and one script argument, used for subscript and superscript forms.
MathSubSuperscript
MhtmlDiagnostic
MhtmlReadResult
MhtmlWriteResult
NotePolicy
A complete visible note policy. start is one-based.
NumberingDefinition
Owned public projection of an abstract numbering definition.
NumberingDefinitionLevel
One explicitly identified level in an inspected numbering definition.
NumberingInstance
Owned public projection of one numbering instance.
NumberingLevel
Resolved reader metadata for one numbering definition level.
NumberingLevelOverride
One typed override owned by a numbering instance.
OdtDiagnostic
OdtReadResult
OdtWriteResult
Serialized ODT bytes together with every lossy-conversion diagnostic.
OutlineNode
A node in the document outline tree.
PackageReadLimits
Resource limits applied while expanding an OPC ZIP archive.
PictureAnchor
Floating placement for a picture or text box.
PictureCrop
Picture crop in DrawingML thousandths of one percent.
PictureOccurrence
Frozen facts for one admitted physical picture in a checked paragraph. Relationship IDs identify media, not drawing occurrences.
PictureOptions
Options for one story-scoped picture.
RasterOptions
Options for raster image export.
RedactionReport
Counts of exact literal replacements made by Document::redact_text.
RenderOptions
Options that select a native document render projection.
ReplacementCountMismatch
The pair of a Document::try_replace_all_expected batch whose count differed from the count its caller expected.
RevisionRef
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.
RtfReadResult
A converted document together with every lossy-conversion diagnostic.
RtfWriteResult
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 start and exclusive at end.
Section
A mutable borrowed view of one section in document order.
SectionRef
An immutable borrowed view of one section in document order.
SectionStory
The effective header or footer story selected for one section variant.
SequenceOptions
Switches governing one authored sequence field.
SettingsDiagnostic
One supported settings child the typed model could not own.
StoryId
Stable owner identity for one operation over an opened document.
StoryItemRef
A borrowed view of one supported story item.
StoryItemSnapshot
One owned story-item projection materialized from a single story inventory.
StoryRangeRef
One immutable pair of accepted-view story positions.
StoryRevision
One owned tracked revision and the Word story that holds it.
StoryRunPosition
A stable insertion point between runs in a checked story paragraph.
StoryRunRange
A half-open run range within one checked story owner.
StoryText
The accepted-view text of one story that the body view leaves out.
StoryTextItem
One direct paragraph or block content control of a StoryText.
SvgDiagnostic
One stable diagnostic produced while lowering a page to SVG.
SvgRenderResult
One self-contained SVG page and its ordered diagnostics.
TableOfAuthoritiesOptions
Native category, heading and passim selection for authorities.
TableOfFiguresOptions
A caption-selected TOC, independent of the TOC sequence page-prefix switch.
TcField
A validated table-of-contents entry request.
TextBoxOptions
Options for one floating Word text box.
TextDiagnostic
A diagnostic accompanying an owned accepted text projection.
TextReport
The CLI-compatible text presentation and its explicit source scope.
TextWatermarkOptions
Appearance of one section-variant text watermark.
ThemeFontLanguage
Default document theme languages from w:themeFontLang.
TocField
A validated table-of-contents rebuild request.
TocRebuildReport
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.
UnsupportedXmlRef
A borrowed fact for content the compatibility reader does not model.
ValidationFinding
One stable section validation fact, in document order.
ValidationReport
Read-only validation results over the current document.

Enums§

AcceptedRunPathSegment
One recursive step to a visible accepted-view run.
BarcodeCaseStyle
An ITF14 case style accepted by \c.
BarcodeKind
A barcode type accepted by Word’s barcode field grammar.
BarcodePointOfSaleStyle
A point-of-sale style accepted by \p.
BibliographyAuthor
Personal or corporate authorship. Corporate is legal only for Author and Performer.
BibliographyContributorRole
A standard contributor role in the ordered author list.
BibliographySourceField
A standard textual source property, including repeated occurrences.
BibliographySourceKind
The seventeen standard bibliography source classifications.
BibliographyStyle
A pinned installed Word bibliography style edition.
BodyContentRef
One body child exposed through the compatibility reader facade.
BodyItemRef
One direct child of a document body, in source order.
BuildingBlockKind
The supported classification of a glossary entry.
CharacterSpacingControl
Document-wide character spacing compression behavior.
ChartKind
One supported two-dimensional chart family.
ComparisonGranularity
The text boundary used when generating content revisions.
ComparisonStoryKind
A Word story category that can be excluded from document comparison.
CompatibilityOption
The complete closed CT_Compat on-off child set.
CrossReferenceNumber
Numbering context requested by a cross-reference.
CryptAlgorithmClass
The algorithm class recorded by Word.
CryptAlgorithmType
The algorithm type recorded by Word.
CryptProviderType
The cryptographic provider category recorded by Word.
CustomPropertyValue
A typed value stored in a custom document property.
DocumentView
The document view Word opens with, from w:view.
DrawingHorizontalAlignment
Horizontal alignment used instead of a floating drawing offset.
DrawingHorizontalRelativeFrom
Horizontal frame used to position a floating Word drawing.
DrawingVerticalAlignment
Vertical alignment used instead of a floating drawing offset.
DrawingVerticalRelativeFrom
Vertical frame used to position a floating Word drawing.
DrawingWrap
Text wrapping policy for a floating Word drawing.
EmbeddedContentKind
Executable or host-activated content owned by a Word package.
EmbeddedFontKind
The font-table slot occupied by an embedded font face.
EmbeddedMutationPolicy
Explicit handling for signature evidence invalidated by an embedded mutation.
EmbeddedSignatureState
Presence and known mutation state of signature evidence for one payload.
Error
FieldOutcome
A pure field-evaluation decision.
FractionType
Fraction bar form.
HdrFtrType
Header/footer reference type in section properties.
HeaderFooterKind
Whether a section story is a header or a footer.
IssueSeverity
Severity level for accessibility issues.
LegacyFormFieldKind
The bounded legacy form kind projected from w:ffData.
LegacyFormFieldValue
The current value stored by one legacy form field.
LegendPosition
The five ChartML legend positions.
LimitLocation
ListLevelRestart
Explicit restart behavior for a numbering level.
ListLevelSuffix
The layout item emitted between a list marker and paragraph content.
ListNumberFormat
Numbering format for one level of a custom list definition.
MailMergeControl
A validated mail-merge control decision.
MailMergeDestination
The mail-merge destination from w:destination.
MailMergeDocumentType
The mail-merge output category from w:mainDocumentType.
MailMergeValue
A scalar value accepted by a rich mail merge field.
MathExpression
One expression in the normalized OfficeMath tree.
MathJustification
MathScriptStyle
Script category for a math run.
MathStyle
Mathematical glyph style.
MatrixBaseJustification
NoteFamily
Which of Word’s independent note streams a policy governs.
NoteNumberFormat
Marker formats the native renderer can reproduce.
NotePlacement
Boundary at which note content appears.
NoteRestart
Boundary at which numeric note markers start over.
NoteSpecialRecord
Special content placed before or after a note that continues across pages.
NumberingFormat
The numbering format reported by the read-only numbering projection.
OfficeMath
Inline or display OfficeMath at a paragraph boundary.
PdfConformance
An archival conformance level supported by the PDF backend.
ProofState
Whether Word considers a proofing pass current, from w:proofState.
ProtectionMode
The editing operation permitted by w:documentProtection.
RasterFormat
Image container and encoding options for raster output.
RasterOutput
Encoded raster output.
RevisionKind
The modeled tracked-change element kind.
RevisionStyle
How the tracked view marks revisions. The accepted view shows none.
RevisionView
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 on w:em/@w:val.
ST_PTabAlignment
ST_PTabAlignment — how content aligns against a positional tab.
ST_PTabLeader
ST_PTabLeader — the leader drawn across a positional tab gap.
ST_PTabRelativeTo
ST_PTabRelativeTo — what a positional tab position is measured from.
ST_RubyAlign
ST_RubyAlign — the horizontal distribution of the phonetic line over the base line, on w:rubyAlign/@w:val.
ST_TextEffect
ST_TextEffect — the animated text effect on w:effect/@w:val.
SettingsDiagnosticReason
Why a supported settings child produced no typed value.
SpecialCharacter
A Word special character run child.
StoryError
A location resolution failure from the container-neutral story API.
StoryItemKind
The supported kind of one item in a story.
StoryKind
A container in the WordprocessingML story graph.
StoryRangeKind
The four paired marker families supported by checked story ranges.
StyleType
The type of a style.
TableStyleRegion
One conditional table-style region, in Word’s increasing-priority order.
TextBoxDirection
Text flow direction inside an authored Word text box.
TocEntrySelection
Which TC entries contribute to a table of contents.
VMerge
Vertical merge state for a cell.
ValidationSeverity
Severity of a document section validation finding.
WordCreationProfile
Completeness and package class for a newly authored Word document.
WordPackageClass
The package class declared by a Word main document part.
ZoomKind
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.

Type Aliases§

Result